CORS problem on all browsers with iOS 13.31

Hi,

I used the browser (Safari / Edge / Chrome) on my iPhone to access my application and found that I cannot access the js resource file normally.

The code snippet looks like this: <script type = 'module' src = 'main.js'>


After my research, I found when requesting JS resources, since type = 'module', it became a cross-domain request. Due to cross-domain, the required cookies are missing when requesting main.js on Browser, which causes the page to not display properly.


This is the test result I did on iOS 13.31 and Mac OS 10.15.3. Y means resources can be loaded normally, N means resources cannot be loaded normally.




iOS 13.31

Mac OS 10.15.3

Edge

N

Y

Chrome

N

Y

Safari

N

N


My question:

Is this related to the browser kernel?

If it is related to the kernel, is this a feature or a bug?

How should we solve the problem that main.js does not load properly in these browsers?


Thanks.

Replies

I'm having the exact same problem. I don't have a Mac, so I can't test myself, but I was working with a user to diagnose/troubleshoot this. I tried setting the crossorigin attribute on the script element, but that doesn't seem to make any difference. I was looking here


https://jakearchibald.com/2017/es-modules-in-browsers/


under the "Credentials by default" section. I'll keep working at it, but testing is tedious. If anyone has any insight it would be greatly appreciated.

Hi,

I did have the same problem and for me the solution was to include
crossorigin="use-credentials" in all script tags for .js-files with type="module"

Hope this will help.