cancel
Showing results for 
Search instead for 
Did you mean: 

Chrome blocking Pdf content accessed via media url

mohanish1990
Explorer
0 Kudos

On our eShop we are trying to embed the pdf on jsp page via media relative url using getURL() method. Doing this in latest version of chrome 88+ it's blocking the content of media to be rendered while FireFox and IE Edge shows the pdf fine.

Any clues what need to be done?

Accepted Solutions (1)

Accepted Solutions (1)

mohanish1990
Explorer

I found solution that why chrome is blocking pdf media and it's because of an attribute in http response namely Content-Security-Policy which chrome is attaching in response with value as sandbox and thus it block the media. However this attribute isn't available in response on FF & IE.

So as a solution I found a document on sap where by local property media attribues can be added or value can be modified and hence added below property in local.properties file and things started working in chrome as usual:

media.set.header.Content-Security-Policy=disable

reference:
https://help.sap.com/viewer/d0224eca81e249cb821f2cdf45a82ace/2005/en-US/8c0f64c786691014aa95f9f6b572...
https://stackoverflow.com/questions/66205446/pdf-hosted-over-rest-interface-returns-err-blocked-by-c...

Hope this information may help others with same problem.

Answers (1)

Answers (1)

geffchang
Active Contributor
0 Kudos

I don't know if it's going to work, but have you tried the `Media.downloadURL` attribute?

mohanish1990
Explorer

hey Geff Chang,

Thanks for replyinh. Yes I tried with all attributes avaiable in Media model with which url can be retreived and used to access the media but none worked for chrome. And as I mentioned with same media url things works on IE and FF.

Apparently I found solution that why chrome is blocking pdf media and it's because of an attribute in http response namely Content-Security-Policy which chrome is attaching in response with value as sandbox and thus it block the media. However this attribute isn't available in response on FF & IE.

So as a solution I found a document on sap where by local property media attribues can be added or value can be modified and hence added below property in local.properties file and things started working in chrome as usual:

media.set.header.Content-Security-Policy=disable

reference: https://help.sap.com/viewer/d0224eca81e249cb821f2cdf45a82ace/2005/en-US/8c0f64c786691014aa95f9f6b572...

Hope this information may help others with same problem.

geffchang
Active Contributor
mohanish1990

Thank you for sharing your findings. I think you should make it an official Answer and accept it. 🙂