React-pdf: "Failed to load PDF file." when using a URL/Parameter object.

Created on 24 Jan 2018  路  4Comments  路  Source: wojtekmaj/react-pdf

2018-01-24 3 23 08

2018-01-24 3 19 26
Hello Wojciech Maj,

I have an problem trying to load PDFs from a URL/Parameter object.

I am using latest version react-pdf2.5.2, react-6.2.0, with the latest version of create-react-app.
I asked PHP to solve the problem of Same-origin policy by adding "Access-Control-Allow-Origin: '*'", but failed. There is no way to solve the problem.
Console output: Failed to load http://139.224.220.33:8868/Upload/video/20180112/1515721300451425.pdf: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Using onLoadError/onSourceError callbacks, i get the message 'onSourceSuccess : undefined, onLoadError: UnknownErrorException {name: "UnknownErrorException", message: "Failed to fetch", details: "UnknownErrorException: Failed to fetch"}'.

Thank you very much!

question

Most helpful comment

Thanks for your time.
It's a pleasure to have your help.

All 4 comments

Hello,
that topic has already been discussed in #36.

I'm afraid I can't be more clear than console output you got - Access-Control-Allow-Origin header is still missing so the request is still blocked.

Let me know if I can help you with anything else!

Hi,
Thanks awesome. Thanks for the quick response!
I had read the discussed of #36 before i asked.The PHP can solve cross-domain problems by setting "Access Control-Allow-Origin: '*' or building a simple proxy to pass the file through the server, but here it is invalid. Could you give some advice to the PHP?
Thank you in advance!

I'm no expert in PHP, sorry. You'd need to ask somewhere else. All I know is that your server does not set this HTTP header, and that's why you see this error.

Thanks for your time.
It's a pleasure to have your help.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

douglasrcjames picture douglasrcjames  路  4Comments

Vanals picture Vanals  路  4Comments

Crackiii picture Crackiii  路  3Comments

zambony picture zambony  路  3Comments

shivekkhurana picture shivekkhurana  路  4Comments