helmet: After update issue ERR_BLOCKED_BY_RESPONSE
I am getting this error after update
net::ERR_BLOCKED_BY_RESPONSE.NotSameOriginAfterDefaultedToSameOriginByCoep 200
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 5
- Comments: 27 (13 by maintainers)
tl;dr: disable the
Cross-Origin-Embedder-Policyheader, enabled by default in Helmet v5.Helmet v5 sets the the
Cross-Origin-Embedder-PolicyHTTP response header torequire-corp. (This was possible in Helmet v4, but it was off by default, so most people didn’t use it.)Setting this header means that loading cross-origin resources (like an image from another resource) is trickier. For example, loading a cross-origin like this…
…won’t work unless
example.comexplicitly allows it, by setting some response headers of its own. Your browser will try to loadexample.com/image.png, and if it’s not explicitly allowed, your browser will drop the response.To fix this, you can prevent Helmet from setting the
Cross-Origin-Embedder-Policyheader, like this:I made a small sample app you can use to play around with this. In my testing, it doesn’t seem to work in HTTP but it does over HTTPS, which might explain why things only break in production.
I think this solves the problem so I’m going to close this issue. Let me know if that’s wrong and I’ll reopen!
@K-404 Not quite. Your options are:
Use the top-level Helmet and disable the
crossOriginEmbedderPolicymiddleware.I do not recommend this, but you can use the top-level Helmet and then manually remove the
Cross-Origin-Embedder-Policyheader later.This should work, but it couples two middlewares. Why not just skip it at the top level?
I do not recommend this, but you can break Helmet into its smaller middlewares and skip
helmet.crossOriginEmbedderPolicy.This should work, but it will make Helmet harder to upgrade in the future if middlewares are added or removed.
Hope this helps!
@amitagrawal11 Good idea. I’ll consider creating a separate resource for this.
@manuelpoelzl Thanks for this. I’ll take a look later today.
Hi! After I am also affected by the error and read along here, I quickly created an app on codesandbox, which shows the problem https://codesandbox.io/s/elegant-sinoussi-v9o06?file=/app.js
I am trying to generate an avatar using https://eu.ui-avatars.com/api/?name=John+Doe , and this is exactly where this error occurs, as @krishnaTORQUE already describes, it also occurs here with the subdomain.
Attached is also a screenshot showing the error
The is showing in Devtools
net::ERR_BLOCKED_BY_RESPONSE.NotSameOriginAfterDefaultedToSameOriginByCoep 200Helmet Config
This same code works in
v4.xbut not inv5.x