senny / pdfjs_viewer-rails

PDF.js viewer packaged as a Rails engine.
MIT License
114 stars 174 forks source link

Getting Error file origin does not match viewer's #42

Open srikanthcx opened 6 years ago

srikanthcx commented 6 years ago

I am getting error file origin does not match viewer's. so please help me on this. we are using s3 for storage and i have configured CORS with cross origin. But i am getting above error. So please can anbody help me on this. pdf-error

gordonbisnor commented 6 years ago

@srikanthcx Wondering if you might need to look into HOSTED_VIEWER_ORIGINS_OPTIONS ?

siegy22 commented 6 years ago

Can you open up the dev tools and show the response?

e.g.:

screen shot 2018-01-09 at 15 10 35
srikanthcx commented 6 years ago

hi siegy22 here the response iam getting

Request URL:https://myhclub.herokuapp.com/pdfjs/full?file=https%3A%2F%2Fhclub-dev.s3.amazonaws.com%2Fuploads%2Fmagazine%2Fmagazine%2F2%2Fmagazine.pdf
Request Method:GET
Status Code:304 Not Modified
Remote Address:54.243.113.132:443
Referrer Policy:no-referrer-when-downgrade

Response Headers

Cache-Control:max-age=0, private, must-revalidate
Connection:keep-alive
Content-Length:0
Date:Tue, 09 Jan 2018 14:39:10 GMT
Etag:W/"bfb7b8a434ba09f199cac6cea21b13f8"
Server:Cowboy
Strict-Transport-Security:max-age=15552000; includeSubDomains
Via:1.1 vegur
X-Content-Type-Options:nosniff
X-Frame-Options:SAMEORIGIN
X-Request-Id:4e9d87ab-81a7-428d-93b3-0c987e7f951e
X-Runtime:0.004548
X-Xss-Protection:1; mode=block

Request Headers

Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding:gzip, deflate, br
Accept-Language:en-US,en;q=0.9
Cache-Control:max-age=0
Connection:keep-alive
Host:myhclub.herokuapp.com
If-None-Match:W/"bfb7b8a434ba09f199cac6cea21b13f8"
Referer:https://myhclub.herokuapp.com/profiles/3
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.108 Safari/537.36
Query String Parameters
view source
view URL encoded
file:https://hclub-dev.s3.amazonaws.com/uploads/magazine/magazine/2/magazine.pdf
siegy22 commented 6 years ago

@srikanthcx there you can see that there are no Access-Control-.. headers, they control the CORS things, please make sure to properly set these up.

See: https://github.com/senny/pdfjs_viewer-rails#setting-up-cors

srikanthcx commented 6 years ago

@siegy22 i have configured it but still iam getting error.

raykin commented 5 years ago

@gordonbisnor Do you know how to get HOSTED_VIEWER_ORIGINS_OPTIONS from global?

raykin commented 5 years ago

@srikanthcx I got same problem when I use it in custom angular wrapper(but I don't think the problem is related with this wrapper). I add custom host into HOSTED_VIEWER_ORIGINS_OPTIONS to fix it see https://github.com/raykin/pdfjs_viewer-rails It probably have better solution.

srikanthreddy919 commented 5 years ago

K got it, thanks @raykin

IanPurdom commented 4 years ago

Hey, same issue here. No other solution than Raykin's ? I've updated HOSTED_VIEWER_ORIGINS_OPTIONS but I still get the error message : "file origin does not match viewer's"

Any help appreciated.

IanPurdom commented 4 years ago

I commented the code below within viewer.js and now it's working.

if (fileOrigin !== viewerOrigin) { throw new Error('file origin does not match viewer\'s'); }