0

Proxy settings work when I run locally on the browser.

When I run it on the device using:

ionic cordova run android --device --livereload

I get the error:

Failed to load http://localhost:5984/mobilehosstest: 
Response to preflight request doesn't pass access control check: 
No 'Access-Control-Allow-Origin' header is present on the requested resource. 
Origin 'http://172.22.4.13:8100' is therefore not allowed access.
The response had HTTP status code 401.

The question is why is it trying to load from localhost:5984. If it was loading from localhost:8100 or http://172.22.4.13:8100, the proxies would work as they work in the browser.

Its something to do with the livereload server but I don't know how to configure it.

Sumama Waheed
  • 3,579
  • 3
  • 18
  • 32

1 Answers1

-1

Running the following command adds a proxy when running on an Android device.

ionic cordova run android -lc

You have to have your Android device connected to your computer. The following are my environment configurations.

@ionic/cli-utils  : 1.19.1
ionic (Ionic CLI) : 3.19.1
cordova (Cordova CLI) : 8.0.0

Also, make sure your ionic.config.json has the proxy added.

jpCharger
  • 109
  • 2