PDF Embedder Documentation

Documentation, Reference Materials, and Tutorials for PDF Embedder

Error: URL to the PDF file must be on exactly the same domain as the current web page

You will usually see this error in your browser because your PDF does not sit on the same domain as the current page on your site.

For example, if you access the page https://www.example.com/ and see this error message:

Error: URL to the PDF file must be on exactly the same domain as the current web pageCode language: JavaScript (javascript)

or maybe this one:

Failed to Fetch

while retrieving the PDF file at this location: https://example.com/wp-content/uploads/2024/02/file.pdf – this is because the shortcode for the embedded document references the URL on example.com domain whereas the page is sitting on www.example.com.

The www part is important – it references a different domain to the PDF’s URL that does not contain www.

For security reasons, browsers are not allowed to load the PDF from a different domain.

Let’s say your site is available via both www.example.com and example.com. Then that’s an inconsistency that is also confusing to search engines and users.

To fix this, ask your web hosting company to make it consistent – for example, to redirect users directly from www.example.com to example.com, so everyone is using the same domain.

Then, you will need to ensure all your PDF Embedder shortcodes refer to the PDF’s URL in the new preferred manner. Various “search and replace” plugins (or the appropriate wp-cli command) may help you to make those changes all over your content.

Sometimes, the problem might be that WordPress is configured to upload PDFs to media.example.com, or something similar, perhaps due to a content-delivery plugin that is attempting to speed up your site. It may still be possible to load PDFs hosted on a different domain, at least if you can set up the configuration of that domain – see Hosting PDFs on other services such as Amazon S3.

It is also possible that a PDF URL is being prevented from loading by a browser Ad Blocker. In the browser console, this shows up as an error net::ERR_BLOCKED_BY_CLIENT. To fix this, be sure that the PDF file name does not contain any words such as advertisement, advert, ad, ads, click, double-click, and others – which are trigger words for Ad Blockers.

If you want help from us in investigating your issue, purchase PDF Embedder Premium to receive our Premium support.

Still have questions? We’re here to help!

Last Modified: