After trying to upload my working app to the store, I was encountered with an error message from app store connect saying that I'm not able to use the UIWebview anymore since it's been deprecated so I've been forced to upgrade to WKWebView.
I followed the answer for this question
When I now try and log into my app, I get these errors on the Safari console:
Origin ionic://localhost is not allowed by Access-Control-Allow-Origin
XMLHttpRequest cannot load https://www.demo.mywebsite.com/mobile/pages/login due to access control checks
Failed to load resources: Origin ionic://localhost is not allowed by Access-Control-Allow-Origin.
In my config.xml I have this
<access origin="http://localhost:8080/*" />
<allow-navigation href="*" />
I also set the headers on my server PHP files via this way:
header("Access-Control-Allow-Origin: http://localhost:8080/*");
header("Content-Type: application/json");
header("Access-Control-Allow-Headers: content-type,authorization");
header("Access-Control-Allow-Credentials: true");
I have my website hosted on Windows Server 2016. Prior to the WKWebView upgrade, it was all working fine but now, i'm not able to use the app at all as it contains a lot of HTTP requests.
UPDATE
I've just made these changes:
<access origin="*" />
<allow-navigation href="*" />
As well as this on my server file:
header("Access-Control-Allow-Origin: *");
I no longer get the ionic://localhost
error and the Failed to load resources
error but I am getting this error:
Cannot use wildcard in Access-Control-Allow-Origin when credentials flag is true.
question from:
https://stackoverflow.com/questions/65851199/xmlhttprequest-faults-after-wkwebview-upgrade-on-ionic-v1-project-app 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…