# Pdf viewer issue

**URL:** <https://pdfjs.community/t/pdf-viewer-issue/3506>\
**Category:** Technical Support\
**Created:** [November 6, 2024, 2:07pm UTC](https://pdfjs.community/t/pdf-viewer-issue/3506 "2024-11-06T14:07:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![marwa.y.salih](https://avatars.discourse-cdn.com/v4/letter/m/74df32/32.png) [@marwa.y.salih](https://pdfjs.community/u/marwa.y.salih)\
**Post date:** [November 6, 2024, 2:07pm UTC](https://pdfjs.community/t/pdf-viewer-issue/3506/1 "2024-11-06T14:07:50Z")

</div>

am using PDFJSExpress

**PDF.js Express Version** :

“@pdftron/pdfjs-express”: “^8.7.5”,  
“@pdftron/pdfjs-express-viewer”: “^8.7.5”,  
“@react-pdf-viewer/core”: “^3.12.0”,

**Expected behaviour**  
the pdf view is not working it gives this error [https://example.com/n.pdf](https://example.com/n.pdf). cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at

```javascript
useEffect(() => {
    // Only initialize WebViewer if documentUrl exists and WebViewer is not already initialized
    const viewerElement = document.getElementById('viewer');
    if (documentUrl && !viewerElement.dataset.initialized) {
      WebViewer({
        path: '/pdfjsexpress', 
        licenseKey: '....', 
        initialDoc: documentUrl,
      }, viewerElement)
        .then(instance => {
          const { UI } = instance;
          UI.disableElements(['downloadButton', 'printButton']);
          
          UI.setHeaderItems(header => {
            header.update([
              { type: 'toggleElementButton', element: 'leftPanelButton' },
              { type: 'toggleElementButton', element: 'searchButton' },
              { type: 'spacer' },
              { type: 'toggleElementButton', element: 'zoomOverlayButton' },
            ]);
          });

          // Mark the viewer as initialized
          viewerElement.dataset.initialized = true;
        })
        .catch(error => {
          console.error("Error initializing PDF.js Express:", error);
        });
    }
  }, [documentUrl]);

  

```

---

<div class="post-metadata">

**Author:** ![darian.chen](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@darian.chen](https://pdfjs.community/u/darian.chen)\
**Post date:** [November 6, 2024, 5:14pm UTC](https://pdfjs.community/t/pdf-viewer-issue/3506/2 "2024-11-06T17:14:01Z")

</div>

Hello Marwa,

You may need to modify the server hosting the PDF file (`https://example.com/n.pdf`) to include the necessary CORS headers in its response. Specifically, the `Access-Control-Allow-Origin` header should be set to allow requests from the domain where your application is hosted.

Best Regards,  
Darian
