Donaldcwl / browser-image-compression

Image compression in web browser
MIT License
1.31k stars 161 forks source link

web worker failing on chrome with adblock turned ON , even after webworker is set to false. #22

Closed FaizanZahid closed 2 years ago

FaizanZahid commented 5 years ago

Refused to create a worker from 'blob:https://site.com/3e9ce499-7750-4d8c-896b-7db16d4677c6' because it violates the following Content Security Policy directive: "script-src 'self' * 'unsafe-inline'". Note that 'worker-src' was not explicitly set, so 'script-src' is used as a fallback.

(anonymous) @ browser.img.compress.js:1 (anonymous) @ browser.img.compress.js:1 (anonymous) @ browser.img.compress.js:1 (anonymous) @ browser.img.compress.js:1 browser.img.compress.js:1 Uncaught DOMException: Failed to construct 'Worker': Access to the script at 'blob:https://site.com/3e9ce499-7750-4d8c-896b-7db16d4677c6' is denied by the document's Content Security Policy. at https://site.com/js/browser.img.compress.js:1:7705 at https://site.com/js/browser.img.compress.js:1:7770 at https://site.com/js/browser.img.compress.js:1:165 at https://site.com/js/browser.img.compress.js:1:169

Any way to fix this, i have even turned off use web worker option by false.

Donaldcwl commented 4 years ago

@FaizanZahid Please check if the issue still happens in the latest release v1.0.10. Thanks!

marvinguors commented 3 years ago

@Donaldcwl there is a bug here s = "boolean" != typeof t.useWebWorker || t.useWebWorker. If miss useWebWorker in option, useWebWorker is not false/boolean here. So createWorker still be called. I must set useWebWorker: false to disable Worker creation.

For CSP error, adding worker-src 'self' blob: to server side response header content-security-policy should works.