|
Rank: Newbie Groups: Member
Joined: 7/15/2019 Posts: 4
|
After updating to 21 version, we start to get the cors error below when converting HTML to pdf. We load font in html as this <link rel="stylesheet" href="https://use.typekit.net/vok2dsn.css">, and we don't see any error rendering html in browser. Web page loading JavaScript error: Access to font at 'https://use.typekit.net/af/437c3d/00000000000000003b9b0932/27/a?primer=7cdcb44be4a7db8877ffa5c0007b8dd865b3bbc383831fe2ea177f62257a9191&fvd=n3&v=3' from origin 'http://localhost:4200' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status. Any idea how to solve this? Thanks.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi,
We tested this CSS link here and it works fine. Where do you see the "Web page loading JavaScript error" message?
Thanks
|
|
Rank: Newbie Groups: Member
Joined: 7/15/2019 Posts: 4
|
Hi, I see this error in WebViewCallback().OnConsolMessage(), it shows as a javascript console error.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi, Can you try to isolate the problem into a test project and send the test project to us? See here for more details: https://www.essentialobjects.com/forum/test_project.aspxThanks!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi,
We have looked into the test project you sent to us. The root of the problem is you have HtmlToPdfOptions.NoCache set to true. Setting this property to true would trigger the CORS preflight request, which the server would response with an 404 error code. This would terminate the request in its preflight stage. To avoid this problem, you would need to remove the line that sets NoCache to true.
Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 4/6/2015 Posts: 33
|
We use WebView.RegisterResourceHandler to process a custom scheme. This has stopped working with the latest release 21.2.70.0 x64.
We load: o Index.html as bnimble://bnimble.com//Index.html. This file contains a script for development.js, relatively referenced. o development.js loads and starts to run o development.js tries to load a json file, also relatively referenced.
At this point, we now get the following DevTools error in the console:
development.js:43 Access to XMLHttpRequest at 'bnimble://bnimble.com/bNimbleWeb/app.json' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, chrome-untrusted, https.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
David Robinson wrote:We use WebView.RegisterResourceHandler to process a custom scheme. This has stopped working with the latest release 21.2.70.0 x64.
We load: o Index.html as bnimble://bnimble.com//Index.html. This file contains a script for development.js, relatively referenced. o development.js loads and starts to run o development.js tries to load a json file, also relatively referenced.
At this point, we now get the following DevTools error in the console:
development.js:43 Access to XMLHttpRequest at 'bnimble://bnimble.com/bNimbleWeb/app.json' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, chrome-untrusted, https.
Have you tried to use http/https as the protocol instead of bnimble? Many CORS related behaviors are highly dependents on HTTP/HTTPs since they rely on http headers. You do not have to use your own special protocol name when you use custom resource handler. Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 4/6/2015 Posts: 33
|
Thank you. That worked.
|
|