Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capacitor - Set origin for cors

Is it possible to set a default origin of https://example.org as opposed to the standard http://localhost on an Android Capacitor app?

like image 241
denski Avatar asked Dec 13 '19 09:12

denski


1 Answers

The origin is handled by the webview and depends on the url where the app is served, so you can’t change the origin directly, but you can change the url capacitor uses, which will change the origin. To change the url, configure hostname and androidSchene properties of server object in capacitor.config.json

"server": {
    "hostname": "example.org",
    "androidScheme": "https"
}

https://capacitor.ionicframework.com/docs/basics/configuring-your-app#common-configuration

like image 52
jcesarmobile Avatar answered Oct 04 '22 22:10

jcesarmobile