Which product are you using?
PDF.js Express Version
Detailed description of issue
Using Create React App, PDFs do not display when project has been run as build. Instead, the iframe just shows a redirect to the main app index.
This problem can be seen even by running a build version of the Create React App demo you have provided in Github. GitHub - pdfjs-express/pdfjs-express-viewer-react-sample
Expected behaviour
PDFs should load in iframe, just as in development mode.
Does your issue happen with every document, or just one?
All documents
Link to document
Document is in public/files
in dev mode, and gets copied to build/files in build version.
Code snippet
...
useEffect(() => {
WebViewer(
{
/** Currently using a free tier, so not worried about this being is source code */
licenseKey: "XXXXXXXX",
path: "/webviewer/lib",
initialDoc: "/files/document.pdf",
},
viewer.current
).then((instance: any) => {
const { Core } = instance;
// adding an event listener for when the page number has changed
Core.documentViewer.addEventListener(
"pageNumberUpdated",
(pageNumber: any) => {
if (pageNumber === 8) {
setViewedEntireDoc(true);
}
}
);
});
}, []);
...