electron-vite / electron-vite-react

:electron: Electron + Vite + React + Sass boilerplate.
https://electron-vite.github.io
MIT License
1.93k stars 240 forks source link

[Help] @react-pdf_renderer bug #199

Closed Denhope closed 10 months ago

Denhope commented 10 months ago

Hi! In my App I have bug with @react-pdf_renderer , when I generete pdf document This bug only on Vite? When I use Webpack I didn't have this bug If some have any Ideas? please help me.

 @react-pdf_renderer.js?v=840c88b4:104898 RuntimeError: Aborted(CompileError: WebAssembly.instantiate(): Refused to compile or instantiate WebAssembly module because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self' 'unsafe-inline'"). Build with -sASSERTIONS for more info.
at x (@react-pdf_renderer.js?v=840c88b4:11665:16)
at @react-pdf_renderer.js?v=840c88b4:12828:15

/////

@react-pdf_renderer.js?v=840c88b4:11663 Aborted(CompileError: WebAssembly.instantiate(): Refused to compile or instantiate 
WebAssembly module because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: 
"script-src 'self' 'unsafe-inline'")

/////
@react-pdf_renderer.js?v=840c88b4:12827 failed to asynchronously prepare wasm: CompileError: WebAssembly.instantiate(): Refused 
 to compile or instantiate WebAssembly module because 'unsafe-eval' is not an allowed source of script in the following Content 
 Security Policy directive: "script-src 'self' 'unsafe-inline'"
mprandot commented 10 months ago

Looks like the CSP protection.

Probably you will need to change your index.html and add the CSP meta tag.

Example:

    <meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline' 'unsafe-eval';">

Ref: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src

Denhope commented 10 months ago

Thanks