Content Security Policy error for bundle js files
Since a week, I have been receiving below error when I'm trying to use my extension which was working fine. I did not make any change in the code.
Refused to load the script 'chrome-extension://2a0537bb-6706-4dfa-b5f7-c1675289a43c/assets/src/entries/contentScript/primary/main.d2e7ec72.js' because it violates the following Content Security Policy directive: "script-src 'self' 'wasm-unsafe-eval' 'inline-speculation-rules' http://localhost:* http://127.0.0.1:*". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.
The script mentioned above is the bundled script file generated by running vite build
A question has been posted regarding this in stack-overflow.
@AnweshGangula
Hey! I posted a solution in #146
I tried this out, it doesn't seem to solve the issue.
Looks like a similar issue was posted in crxjs: https://github.com/crxjs/chrome-extension-tools/issues/927
Hey. I don't know if you're still having issues, but I fixed it by adding this to my vite config:
// ...
server: { cors: { methods: "GET", origin: "*" } },
// ...
I tried this but now I'm getting below error:
Uncaught (in promise) TypeError: Failed to fetch dynamically imported module: chrome-extension://8b3d4793-99f5-44f3-bf84-004cdf5d9e84/assets/src/entries/contentScript/primary/main.614686f0.js
server: { cors: { methods: "GET", origin: "*" } },
that fixed for me