-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error to load pdf on foreign url with pdf.js #7153
Comments
It's done on purpose, see #6916. Modify viewer.js to include your hosts origins in the HOSTED_VIEWER_ORIGINS list. Closing as answered. |
Thanks @yurydelendik |
|
I did it but I do not know how to call my remote pdf file |
Please explain. Also can you provide the following information:
|
My pdf file is on cloudinary . |
exemple of my url pdf http://res.cloudinary.com/image/upload/v1459791656/my_file.pdf |
I resolve to comment this lines in viewer.js if (fileOrigin !== viewerOrigin) { |
Don't comment out logic. Use console.log() to see if your fileOrigin and viewerOrigin match. Make sure at least one entry in your HOSTED_VIEWER_ORIGINS object matches the viewerOrigin and the "File origin does not match viewer" error will disapper. Add this:
... right above:
I'd bet a nickel you're missing (or have) an added slash at the end of your URL like I did (discovered when console logging those two vars). Hope this helps someone. |
It would be nice to be able to configure HOSTED_VIEWER_ORIGINS array with regex/wildchars. |
In order to allow for non-hard-coded Mozilla domains, I have to modify the source code of a 10k line built file called viewer.js? |
@gildassamuel you save my day!! |
The proper fix is open viewer.js and append your file's host to HOSTED_VIEWER_ORIGINS Don't remove checking code :| |
I have the same issue (file origin does not match viewer's) on UWP with local pdf file. What entry exactly must be added to HOSTED_VIEWER_ORIGINS for a local path ? |
For anyone else using this within an app I had to add 'file://' to allow local paths to work. var HOSTED_VIEWER_ORIGINS = [ |
In my case I was locally coding and I had the same problem and I resolved by adding my local address:
But don`t remove the checking code:
|
I think adding these 2 lines will be a good solution. Your local ip will be detected automatically (wherever you start your application)
|
helped me |
it a very bad problem, any how hant solved yet. Access to fetch at 'https://dmain/file.pdf' from origin 'http://localhost' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled. |
Hello, is there a reason for this ? it's the browser responsability to care about cors policy, not pdfjs i've added |
as @IK77 mentioned, can you please provide a reason for this ? |
This is the correct answer to help me solve the problem, thank you. |
Hello,
I have this error when i want to load pdf from foreign url
Error: file origin does not match viewer's
throw new Error('file origin does not match viewer's');
please help!
The text was updated successfully, but these errors were encountered: