"Blocked plug-in" error in Safari when opening a PDF file

Published on in Safari

Try to add object-src 'self'; to the Content Security Policy. Then your users don't have to download the file to view it.

Table of contents

The problem

I was investigating an issue where Safari failed to display a PDF file. It instead just showed the text "Blocked plug-in."

The problem occurred only in desktop Safari.

The fix

The user could download the file to view it, but that would be cumbersome.

I did some quick googling but didn't find any good results.

Then I noticed that Safari's console showed an error message related to Content Security Policy (CSP).

In the end, the fix was to add object-src 'self'; to the CSP.

Interesting that other browsers don't require that setting.

Read about the object-src CSP directive on MDN.