3

currently I am working on ReactJs project (create-react-app) to open a pdf blob file in the new tab. The code is short and straight forward as below.

window.open(URL.createObjectURL(blob));

Exactly the same code and same browser (new tab for each environment). My local server is work, but my public website is not working, a new tab with blank pdf page!

enter image description here

Until I spend a very long time, I found out if I set the security.csp.enable to false in Firefox config, the blob url is just working fine for my public website. However this is not a correct way as I am not possible to ask my client to set Firefox config, and disable the config might cause security issue.

In addition, I also tried to add the meta to public/index.html

<meta http-equiv="Content-Security-Policy" content="object-src 'self' blob:;" />

But It just won't work.

I am running out of idea. Please shed some light to me. Thanks!

Note:

Other Reference:

karfai
  • 816
  • 1
  • 10
  • 21

0 Answers0