PDF.js Message: file origin does not match viewer's (Amazon S3)
<p>In a Rails app, using the <code>pdfjs_viewer-rails</code> gem (<a href="https://github.com/senny/pdfjs_viewer-rails" rel="nofollow">https://github.com/senny/pdfjs_viewer-rails</a>), I keep seeing this error:</p>

<pre><code>PDF.js v1.3.91 (build: d1e83b5)
Message: file origin does not match viewer's
</code></pre>

<p>I presume this is because the PDF is hosted on Amazon S3, and I have read through the discussion of CORS here (<a href="https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#faq-xhr" rel="nofollow">https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#faq-xhr</a>).  However, I have been unable to assemble a COSR configuration that works.  </p>

<p>My current bucket configuration is: </p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"&gt;
    &lt;CORSRule&gt;
        &lt;AllowedOrigin&gt;*&lt;/AllowedOrigin&gt;
        &lt;AllowedMethod&gt;GET&lt;/AllowedMethod&gt;
        &lt;AllowedHeader&gt;Range&lt;/AllowedHeader&gt;
        &lt;MaxAgeSeconds&gt;3000&lt;/MaxAgeSeconds&gt;
        &lt;ExposeHeader&gt;Accept-Ranges&lt;/ExposeHeader&gt;
        &lt;ExposeHeader&gt;Content-Range&lt;/ExposeHeader&gt;
        &lt;ExposeHeader&gt;Content-Encoding&lt;/ExposeHeader&gt;
        &lt;ExposeHeader&gt;Content-Length&lt;/ExposeHeader&gt;
        &lt;AllowedHeader&gt;Authorization&lt;/AllowedHeader&gt;
    &lt;/CORSRule&gt;
&lt;/CORSConfiguration&gt;
</code></pre>

<p>and just to be safe, in my rails app I have:</p>

<pre><code>config.action_dispatch.default_headers = {
      'Access-Control-Allow-Origin' =&gt; '*',
      'Access-Control-Request-Method' =&gt; %w{GET}.join(",")
    }
</code></pre>

<p>Has anyone else been able to overcome this?  Does anyone know of a CORS policy that works with pdf.js and amazon s3?</p>