RuntimeError: Refused to compile or instantiate WebAssembly module because 'unsafe-eval'
Describe the bug
I have just migrated from CRA to Vite 5.2.0 and as I was testing my app for any issues caused by this I find that I can no longer use @react-pdf/renderer (specifically <PDFDownloadLink />) to create a PDF because of a CSP issue. It still works if I add the unsafe-eval to the CSP string but I'm sure there has to be a better way. I'm also curious as to why it was working before.
Using ASP.NET on the BE with Dotnet 6.
To Reproduce
Running the client app on it's own doesn't throw any errors.
Running the app through the port which then has a websocket to connect to my server is when I'm getting the error.
Previously when using CRA this was not an issue.
I'm wondering if there is some extra config I need to do to handle stuff in VITE which may have been automatically done by CRA.
I'm using "@react-pdf/renderer": "^3.2.0", "vite": "^5.2.0",
On loading the page where I use <PDFDownloadLink /> component I get the error in the screenshot above.
Expected behavior I'm hoping to get it working as it was with CRA without having to use 'unsafe-eval'
Desktop (please complete the following information):
- OS: Windows 10
- Browser Chrome
- React-pdf version 3.2.0
I've seen this issue mentioned in this thread but didn't seem like it was resolved: https://github.com/diegomura/react-pdf/issues/510
+1. am facing this issue too!
+1. am facing this issue too!
I figured it out mate, it's about enforcing a very specific set of resolutions (sub dependency package versions)
@react-pdf/[email protected] @react-pdf/[email protected]
cool! thanks for figuring it out @paul-gansca 👍 setting those specific resolutions fixed it for me as well
+1. am facing this issue too!
I figured it out mate, it's about enforcing a very specific set of resolutions (sub dependency package versions)
@react-pdf/[email protected] @react-pdf/[email protected]
I am still facing the issue, tried these versions and still having the issue.
anyone have any idea?
+1. am facing this issue too!
I figured it out mate, it's about enforcing a very specific set of resolutions (sub dependency package versions) @react-pdf/[email protected] @react-pdf/[email protected]
I am still facing the issue, tried these versions and still having the issue.
anyone have any idea?
Have you checked with "npm ls" that you indeed have these versions?
I was only able to enforce the the sub-dependency version using yarn btw.
@paul-gansca You were right, it wasn't getting the correct packages, I had to roll back yarn.lock to and add it in the "resolutions" and it worked Thank you very much 🙏
any news about this? i continue to have this error....
Good morning,
I tried to apply the "resolution" solution, but today it doesn't seem to work anymore.
Has anyone of you managed to solve the problem? Thank you in advance