title: react-pdf failed to view pdf file from remote url
body: <p>I am trying to view a pdf file inside <code>react pdf</code> but I cannot do that because it failed to load the file. I don't know why, and I have tried these CDNs:</p>
  <ul>
  <li><p><a href="https://cdnjs.com/libraries/pdf.js/2.7.570" rel="nofollow noreferrer">https://cdnjs.com/libraries/pdf.js/2.7.570</a></p>
  </li>
  <li><p><a href="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.7.570/pdf.min.js" rel="nofollow noreferrer">https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.7.570/pdf.min.js</a></p>
  </li>
  </ul>
  <p>One of them keeps loading and the other keeps on giving me an error. Either CORS or <code>fake worker failed</code> error. I need help, thanks in advance.</p>
  <p>This is my code:</p>
  <pre><code>import { Document, Page, pdfjs } from &quot;react-pdf&quot;;
  
  pdfjs.GlobalWorkerOptions.workerSrc =
    &quot;https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.7.570/pdf_viewer.js.map&quot;;
  
  const DocsViewer = ({ link }) =&gt; {
    const [pages, setPages] = useState(null);
    const [pageNumber, setPageNumber] = useState(1);
  
    function onDocumentLoadSuccess({ numPages }) {
      console.log(&quot;object:&quot;, numPages, pages);
      setPages(numPages);
      setPageNumber(1);
    }
  
    return (
      &lt;div className=&quot;property-overview-container property-flex-half&quot;&gt;
        &lt;div className=&quot;description-overview&quot;&gt;
          &lt;Document
            file={
              &quot;https://yahuda.s3.us-east-2.amazonaws.com/4d0970da-f0c7-4a37-9ce4-5c48619a996b.pdf&quot;
            }
            // link={link}
            onLoadSuccess={onDocumentLoadSuccess}
            onLoadError={(error) =&gt; console.log(&quot;Inside Error&quot;, error)}
          &gt;
            &lt;Page pageNumber={pageNumber} style={{ display: &quot;none&quot; }} /&gt;
          &lt;/Document&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    );
  };
  export default DocsViewer;
  </code></pre>