wordpresspdfpolicyreferrerreferrer-policy

Referrer policy problem? PDF Attachment shows blank on Chrome only (multiple Computers)


I have links to PDFs on my site that open the attached PDF file in a new tab. Usually, the new tab opens and the PDF shows just fine. You can scroll it and browse it.

Up until today, there's been no problem. Now all of a sudden, when I click the attachment, the new tab opens but the page remains grey. This only happens with Chrome. I can use another browser and it will show. This is consistent on any computer I try this on.

In developer tools on console it gives the error message as follows: Failed to set referrer policy: The value '' is not one of 'no-referrer', 'no-referrer-when-downgrade', 'origin', 'origin-when-cross-origin', 'same-origin', 'strict-origin', 'strict-origin-when-cross-origin', or 'unsafe-url'. The referrer policy has been left unchanged.

Any ideas how to resolve this and get the PDFs to open and display on Chrome? Also for reference this is a WordPress site Thanks


Solution

  • If your site has a ServiceWorker, there's a bug in Chrome 71 that is causing an issue. Details here: https://bugs.chromium.org/p/chromium/issues/detail?id=918944

    My fix was to essentially tell my SW to simply return the pdf request if detected. I'm sure there are more elegant ways, but I put the following line near the top of my fetch event.

    if( request.url.indexOf('.pdf') !== -1 ){ return; }
    

    If you're not using a SW, try adding rel="noopener noreferrer" to the link.