Refused to create a worker because it violates the following Content Security Policy directive: worker-src #1715
-
Keep seeing this error in the console. MSW still runs, but would like to find the source of the issue.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi, @cmacdonnacha. Why is this happening?It looks like your server has a strict How to resolve it?First, see if you can adjust the If you don't own the server or cannot adjust the said policy, you can look into browser-level whitelisting rules for that. There's nothing we can do on MSW side since it isn't the library's issue. |
Beta Was this translation helpful? Give feedback.
Hi, @cmacdonnacha.
Why is this happening?
It looks like your server has a strict
Content-Security-Policy
defined that only allows certain origins forworker-src
. To my best knowledge,worker-src blob:
translates to: only allow installing workers at theblob:
identifier. Since MSW worker is installed using thehttp:
scheme, it violates the set security policy, raising the error you see.How to resolve it?
First, see if you can adjust the
Content-Security-Policy
values on your server. Those make sense in production but you may have a looser set for development to allow tools like MSW.If you don't own the server or cannot adjust the said policy, you can look into browser-level whitelisting …