Unble to load pdf in the non localhost environment

hello Team,

PDF.js works with localhost and renders pdf. but when using in production documnet content is always blank

Hi there,

Thanks for reaching out to pdfjs express forums,

We will need more information, could you provide any screenshots/videos of the errors including console errors as well as any sample code you are using to load the document/initialize the viewer.
Also if you are using pdf.js express viewer or pro and the version number.

Best regards,
Kevin Kim

No error in the browser log. using the config property to overcome cross origin error.


Following warning is there in the deployed website:
Config file requested to be loaded by origin https://demo.xxxx.com. Please include this origin inside lib/ui/configorigin.txt to allow it to request config files.

Other item noticed is, pdfjsConfig.js file passed as a config is not being called in the deployed website, where as in local its being called in the browser network tab

code used:
custom: JSON.stringify(customData),
config: ${window.location.protocol}//${window.location.host}:${PORT}/public/pdfjsConfig.js,
licenseKey: ‘wyevv42e6IDA38ng99OF’

Hi there,

Have you followed the guide here to setup the config file?
Loading PDF.js Express from a CDN or another origin | Documentation)-copy-assets-to-cdn

Can you share a screenshot of the network request in the production site?

Does it work if you try absolute URL as the path?

Best regards,
Kevin Kim

Thanks alot , it got worked after adding domain in configorigin.txt file.

pdf files are loading now