[iOS] issue of capacitor://locahost

I have a capacitor app which works fine for Android, and for iOS, it’s a little different:

I use vue-cli-plugin-capacitor to run in the development mode, which will set the server://xxx.xxx.xxx.xxx:8080 in the capacitor.config.json, it works.

The problem occurs in the release mode. When I package the app using Xcode and run, the app is running, but some call to the remote server is reject because of CORS restriction:

The request send out from capacitor is:

Content-Type: application/json;charset=UTF-8
Origin: capacitor://localhost
Accept: /
User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148
X-SDK-Version: @cloudbase/js-sdk/1.4.0
x-seqid: ec0772ba0a37d

As I cannot config the allowed Origin start from capacitor://, how to change this origin value to http://localhost?

You can’t, you have to change it on the server.
If you can’t change it on the server because it’s not yours, you can use a proxy or a plugin that uses native connections.

OK, thanks. I have made a plugin for the 3rd party server framework and also use http plugin to send network traffic through native connection, and now everything works fine.