# PDFs not being found in production build of Create React App project

**URL:** <https://pdfjs.community/t/pdfs-not-being-found-in-production-build-of-create-react-app-project/1532>\
**Category:** Technical Support\
**Created:** [March 31, 2022, 10:44pm UTC](https://pdfjs.community/t/pdfs-not-being-found-in-production-build-of-create-react-app-project/1532 "2022-03-31T22:44:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ben](https://avatars.discourse-cdn.com/v4/letter/b/df788c/32.png) [@ben](https://pdfjs.community/u/ben)\
**Post date:** [March 31, 2022, 10:44pm UTC](https://pdfjs.community/t/pdfs-not-being-found-in-production-build-of-create-react-app-project/1532/1 "2022-03-31T22:44:31Z")

</div>

**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](https://github.com/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**

```javascript
...

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);
          }
        }
      );
    });
  }, []);

...

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/1X/ffbcd25c7d423db8d5acd5db201c272f4db306dd.png) [@system](https://pdfjs.community/u/system)\
**Post date:** [March 31, 2022, 10:44pm UTC](https://pdfjs.community/t/pdfs-not-being-found-in-production-build-of-create-react-app-project/1532/3 "2022-03-31T22:44:36Z")

</div>

**Hello, I’m Ron, an automated tech support bot 🤖**

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:
- [Config files](https://pdfjs.express/documentation/learn-more/advanced/config-files.8)
- [Integrating PDF.js Express Viewer into a new Angular project - Sample overview](https://pdfjs.express/documentation/get-started-viewer/angular/new-project#sample-overview)
- [What is PDF.js Express?](https://pdfjs.express/documentation/learn-more/inside-express-viewer.8)

APIs:
- [CoreControls - initPDFWorkerTransports(pdfBackendType, workerHandlers, l)](https://pdfjs.express/api/7.0/CoreControls.html#.initPDFWorkerTransports__anchor)
- [PartRetrievers.ExternalPdfPartRetriever](https://pdfjs.express/api/7.0/PartRetrievers.ExternalPdfPartRetriever.html#__anchor)
- [Core.Annotations.RotationUtils - PathCustomAnnotationRotationMixin()](https://pdfjs.express/api/Core.Annotations.RotationUtils.html#PathCustomAnnotationRotationMixin__anchor)

Forums:
- [How to delete highlight annotation from pdf with pdf js express in react](https://pdfjs.community/t/how-to-delete-highlight-annotation-from-pdf-with-pdf-js-express-in-react/379/1)
- [IE 11 Not work on builded React code](https://pdfjs.community/t/ie-11-not-work-on-builded-react-code/227/1)
- [License key for viewer is not working in an ionic app](https://pdfjs.community/t/license-key-for-viewer-is-not-working-in-an-ionic-app/1436/1)

---

<div class="post-metadata">

**Author:** ![Logan](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/logan/32/13_2.png) [@Logan](https://pdfjs.community/u/Logan)\
**Post date:** [April 1, 2022, 2:16pm UTC](https://pdfjs.community/t/pdfs-not-being-found-in-production-build-of-create-react-app-project/1532/4 "2022-04-01T14:16:52Z")

</div>

Hi there,

Create-React-App redirects all 404s to the main index, which causes this weird loop you’re seeing. This means that `/webviewer/lib` does not exist and is resulting in a 404.

Please ensure your static dependencies are set up correctly and `/webviewer/lib` actually exists on your server.

Thanks!  
Logan

---

<div class="post-metadata">

**Author:** ![nirmalkumar.r](https://avatars.discourse-cdn.com/v4/letter/n/b9bd4f/32.png) [@nirmalkumar.r](https://pdfjs.community/u/nirmalkumar.r)\
**Post date:** [December 5, 2023, 5:41am UTC](https://pdfjs.community/t/pdfs-not-being-found-in-production-build-of-create-react-app-project/1532/5 "2023-12-05T05:41:41Z")

</div>

Hi Logan

Facing similar issue in local build. Working fine in local NPM start execute. Able to confirm all static dependencies inside build under /webviewer/lib. Trying pdfviewer along with [Material Dashboard 2 React: Free MUI & React Admin Template @ Creative Tim](https://www.creative-tim.com/product/material-dashboard-react). Please help me with your inputs.
