Welcome Guest Search | Active Topics | Sign In | Register

CORS error for 21 version Options
jshi
Posted: Monday, July 19, 2021 2:41:31 PM
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.
eo_support
Posted: Monday, July 19, 2021 3:41:43 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,071
Hi,

We tested this CSS link here and it works fine. Where do you see the "Web page loading JavaScript error" message?

Thanks
jshi
Posted: Monday, July 19, 2021 3:49:44 PM
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.
eo_support
Posted: Wednesday, July 21, 2021 1:44:45 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,071
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.aspx

Thanks!
eo_support
Posted: Friday, July 23, 2021 10:35:29 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,071
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!
David Robinson
Posted: Wednesday, October 27, 2021 7:15:55 PM
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.
eo_support
Posted: Thursday, October 28, 2021 2:27:52 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,071
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!
David Robinson
Posted: Friday, October 29, 2021 6:02:20 PM
Rank: Advanced Member
Groups: Member

Joined: 4/6/2015
Posts: 33
Thank you. That worked.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.