# Ionic 4.12 - Running on device gives me CORS error. It ignores proxy config. How to overcome this?

**URL:** <https://forum.ionicframework.com/t/ionic-4-12-running-on-device-gives-me-cors-error-it-ignores-proxy-config-how-to-overcome-this/162553>\
**Category:** Ionic Framework\
**Created:** [April 26, 2019, 12:38pm UTC](https://forum.ionicframework.com/t/ionic-4-12-running-on-device-gives-me-cors-error-it-ignores-proxy-config-how-to-overcome-this/162553 "2019-04-26T12:38:46Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![helenakohan](https://avatars.discourse-cdn.com/v4/letter/h/7feea3/32.png) [@helenakohan](https://forum.ionicframework.com/u/helenakohan)\
**Post date:** [April 26, 2019, 12:38pm UTC](https://forum.ionicframework.com/t/ionic-4-12-running-on-device-gives-me-cors-error-it-ignores-proxy-config-how-to-overcome-this/162553/1 "2019-04-26T12:38:46Z")

</div>

Hi:

I want to run the app on my device but it gives me hard time: (ionic 4.12).  
Running on device gives me CORS error and ignores proxy server config.

It run on localhost:8080 not file:// ? (I test the location at the console of Remote Devices)

10X

---

<div class="post-metadata">

**Author:** ![vivek-23](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/vivek-23/32/125332_2.png) [@vivek-23](https://forum.ionicframework.com/u/vivek-23)\
**Post date:** [April 26, 2019, 1:05pm UTC](https://forum.ionicframework.com/t/ionic-4-12-running-on-device-gives-me-cors-error-it-ignores-proxy-config-how-to-overcome-this/162553/2 "2019-04-26T13:05:33Z")

</div>

I would need more context to debug. What are your API URLs located at?

---

<div class="post-metadata">

**Author:** ![helenakohan](https://avatars.discourse-cdn.com/v4/letter/h/7feea3/32.png) [@helenakohan](https://forum.ionicframework.com/u/helenakohan)\
**Post date:** [April 26, 2019, 2:31pm UTC](https://forum.ionicframework.com/t/ionic-4-12-running-on-device-gives-me-cors-error-it-ignores-proxy-config-how-to-overcome-this/162553/3 "2019-04-26T14:31:57Z")

</div>

Hi 10x for the reply:

It doesn’t matter which api. you can call “[http://api.ionic.com/endpoint](http://api.ionic.com/endpoint)”.

The problem is that when running on android deivice it turns the webview into localhost:8080 instead of file://.

So how do i debug it?

---

<div class="post-metadata">

**Author:** ![vivek-23](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/vivek-23/32/125332_2.png) [@vivek-23](https://forum.ionicframework.com/u/vivek-23)\
**Post date:** [April 26, 2019, 2:38pm UTC](https://forum.ionicframework.com/t/ionic-4-12-running-on-device-gives-me-cors-error-it-ignores-proxy-config-how-to-overcome-this/162553/4 "2019-04-26T14:38:11Z")

</div>

Below link should help.

> [@Simple Ionic 3 App Not Working on Android Device](https://forum.ionicframework.com/t/simple-ionic-3-app-not-working-on-android-device/137047/11):
>
> @dumdem Like he said, the problem is about the Android version (in your case, 4.3) and the new version of the cordova-plugin-ionic-webview. So you can run: cordova plugin rm cordova-plugin-ionic-webview cordova plugin add cordova-plugin-ionic-webview@1.2.1 ionic cordova platforms remove android rm -rf plugins ionic cordova build android The above will: Remove the cordova-plugin-ionic-webview that you are using. Install version 1.2.1 (that supports Android 4.4+, though I don’t know about 4.3)…

---

<div class="post-metadata">

**Author:** ![collinsushigmailcom](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/collinsushigmailcom/32/149051_2.png) [@collinsushigmailcom](https://forum.ionicframework.com/u/collinsushigmailcom)\
**Post date:** [April 26, 2019, 9:21pm UTC](https://forum.ionicframework.com/t/ionic-4-12-running-on-device-gives-me-cors-error-it-ignores-proxy-config-how-to-overcome-this/162553/5 "2019-04-26T21:21:23Z")

</div>

Change your address from [http://localhost:8080](http://localhost:8080) to http://IP\_Address:Server Port Number.

---

<div class="post-metadata">

**Author:** ![helenakohan](https://avatars.discourse-cdn.com/v4/letter/h/7feea3/32.png) [@helenakohan](https://forum.ionicframework.com/u/helenakohan)\
**Post date:** [April 27, 2019, 1:58pm UTC](https://forum.ionicframework.com/t/ionic-4-12-running-on-device-gives-me-cors-error-it-ignores-proxy-config-how-to-overcome-this/162553/6 "2019-04-27T13:58:00Z")

</div>

Thanks but does not work

---

<div class="post-metadata">

**Author:** ![helenakohan](https://avatars.discourse-cdn.com/v4/letter/h/7feea3/32.png) [@helenakohan](https://forum.ionicframework.com/u/helenakohan)\
**Post date:** [April 27, 2019, 2:02pm UTC](https://forum.ionicframework.com/t/ionic-4-12-running-on-device-gives-me-cors-error-it-ignores-proxy-config-how-to-overcome-this/162553/7 "2019-04-27T14:02:47Z")

</div>

10x but this I can’t do because this is how ionic run works on device.

It seems the proxy does not work on running in device

---

<div class="post-metadata">

**Author:** ![vivek-23](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/vivek-23/32/125332_2.png) [@vivek-23](https://forum.ionicframework.com/u/vivek-23)\
**Post date:** [April 27, 2019, 2:25pm UTC](https://forum.ionicframework.com/t/ionic-4-12-running-on-device-gives-me-cors-error-it-ignores-proxy-config-how-to-overcome-this/162553/8 "2019-04-27T14:25:21Z")

</div>

Since I don’t have much information on your ionic version, android platform etc, all I can help you with is links. Look at below links:

> **[Ionic Documentation](https://ionicframework.com/docs/faq/cors)**
>
> Ionic is the app platform for web developers. Build amazing mobile, web, and desktop apps all with one shared code base and open web standards

[https://blog.ionicframework.com/handling-cors-issues-in-ionic/](https://blog.ionicframework.com/handling-cors-issues-in-ionic/)

---

<div class="post-metadata">

**Author:** ![monkeytronics](https://avatars.discourse-cdn.com/v4/letter/m/b5ac83/32.png) [@monkeytronics](https://forum.ionicframework.com/u/monkeytronics)\
**Post date:** [May 8, 2019, 8:04am UTC](https://forum.ionicframework.com/t/ionic-4-12-running-on-device-gives-me-cors-error-it-ignores-proxy-config-how-to-overcome-this/162553/9 "2019-05-08T08:04:43Z")

</div>

Guys. This is ridiculous. I’ve just spent an hour dredging through Stack Overflow and this forum. As far as I can tell, NOBODY knows how to get Proxies to work for Ionic 4. Can someone from ionic maybe put together a demo app with the right stuff in it and post it somewhere. Thousands of hours are being wasted swearing, that should be spent telling other people how great ionic is…

Personally, I’m trying to use the angular httpClient. I want to create a mobile app and a PWA in the end. I like the way httpClient uses observables. So, I spent about a day or 2, tearing out all the native ionic http stuff. According to at least 50% of the opinionated masses (yes the other 50% were on the fence), this is the right thing to do, for more reasons that I care to elaborate here. However, you know where this is going… I get a CORS error on my device when I run devApp or ionic run, so I can’t debug on the device. And I have no idea if it will work when built in the end. Since my app is in tatters right now, I just don’t have the energy to try.

So, adding proxies to your ionic.config.json doesn’t work.  
Creating a proxy.conf.json file which holds a target doesn’t work, no matter whether you point to it from within your angular.json, or you add it explicitly to the command when you run the serve.

So I’m left with no option but to go back to using the native http and sucking up all the above (not actually) mentioned negatives.

## EDIT

I’ve gone back to

> import { Http, Headers, Response } from ‘@angular/http’;

and CORS errors vanishes. I have no idea why, nor do I want to. Perhaps soetime in 2023 when someone has figured out how to get httpClient to work, I’ll upgrade again.

---

<div class="post-metadata">

**Author:** ![helenakohan](https://avatars.discourse-cdn.com/v4/letter/h/7feea3/32.png) [@helenakohan](https://forum.ionicframework.com/u/helenakohan)\
**Post date:** [May 8, 2019, 5:09pm UTC](https://forum.ionicframework.com/t/ionic-4-12-running-on-device-gives-me-cors-error-it-ignores-proxy-config-how-to-overcome-this/162553/10 "2019-05-08T17:09:18Z")

</div>

That didn’t work.

CORS on device just does not work. Because the angular proxy is not activated like on running on browser for some reason

---

<div class="post-metadata">

**Author:** ![helenakohan](https://avatars.discourse-cdn.com/v4/letter/h/7feea3/32.png) [@helenakohan](https://forum.ionicframework.com/u/helenakohan)\
**Post date:** [May 8, 2019, 5:11pm UTC](https://forum.ionicframework.com/t/ionic-4-12-running-on-device-gives-me-cors-error-it-ignores-proxy-config-how-to-overcome-this/162553/11 "2019-05-08T17:11:45Z")

</div>

This is not a solution for me.

I need to use external library to do my calls.

what the hell ionic 4 did?

at 2 it was much simpler

---

<div class="post-metadata">

**Author:** ![marracuene2](https://avatars.discourse-cdn.com/v4/letter/m/b5a626/32.png) [@marracuene2](https://forum.ionicframework.com/u/marracuene2)\
**Post date:** [September 16, 2020, 5:07pm UTC](https://forum.ionicframework.com/t/ionic-4-12-running-on-device-gives-me-cors-error-it-ignores-proxy-config-how-to-overcome-this/162553/12 "2020-09-16T17:07:00Z")

</div>

@helenakohan see this other post on the forum… indeed it seems like Ionic 4 somehow quietly dropped proxy support.

> [@CORS issue while shaping working web app into a native Ionic app for Android w/ capacitor](https://forum.ionicframework.com/t/cors-issue-while-shaping-working-web-app-into-a-native-ionic-app-for-android-w-capacitor/195697):
>
> I’ve been trying to set up this Ionic CLI proxy server following this [guide](https://ionicframework.com/blog/handling-cors-issues-in-ionic/), but it’s from 2015 and I have no idea how to implement it in Angular 10. So when I run my app with a command: ionic capacitor run android --project=myApp -c=production I have this error in Android Studio: E/Capacitor/Console: File: http://localhost/login - Line 0 - Msg: Access to XMLHttpRequest at 'https://remoteServer.com/api/v1/oauth/v2/token' from origin 'http://localhost' has been blocked by CORS policy: Respo…
