# Ionic v1 no 'Access-Control-Allow-Origin'

**URL:** <https://forum.ionicframework.com/t/ionic-v1-no-access-control-allow-origin/136366>\
**Category:** ionic-v1\
**Created:** [July 26, 2018, 3:51pm UTC](https://forum.ionicframework.com/t/ionic-v1-no-access-control-allow-origin/136366 "2018-07-26T15:51:37Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![nicvr](https://avatars.discourse-cdn.com/v4/letter/n/ed8c4c/32.png) [@nicvr](https://forum.ionicframework.com/u/nicvr)\
**Post date:** [July 26, 2018, 3:51pm UTC](https://forum.ionicframework.com/t/ionic-v1-no-access-control-allow-origin/136366/1 "2018-07-26T15:51:38Z")

</div>

Hi to all,

I started a new app with ionic v1 using: cordova 8.0.0, ionic 3.20.0, cordova-android 7.0.0, cordova ios 4.5.4.  
I use v1 because because i have no time to learn typescript now, i just developed 2 app with ionic v1.

All 3 apps share part of code, specifically the one for connecting to our servers, and I expect all of them to connect to the same servers without problems but…

The new app give me this error “Failed to load [http://example.com](http://example.com): No ‘Access-control-Allow-Origin’ header is present on the request source…”

It happens with run command.

whitlist plugin is installed  
 is set in config.xml  
In meta “Content-security-policy’ i tried also ''default-src \*”

As i said, others apps have no problem to connect to same server but they use: cordova 7.0.1, ionic 1.7.16, cordova-android 6.1.0

I search and try many solution but nothing.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Youtch](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/youtch/32/132853_2.png) [@Youtch](https://forum.ionicframework.com/u/Youtch)\
**Post date:** [July 26, 2018, 4:15pm UTC](https://forum.ionicframework.com/t/ionic-v1-no-access-control-allow-origin/136366/2 "2018-07-26T16:15:32Z")

</div>

It can depends of you platform : If you are using Chrome browser you can install this extension, it helped me to fix an API server connection error. You’ll have only to activate “Enable cross-origin ressource sharing” : [https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi?hl=fr](https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi?hl=fr)

---

<div class="post-metadata">

**Author:** ![johnpaulcm](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/johnpaulcm/32/112647_2.png) [@johnpaulcm](https://forum.ionicframework.com/u/johnpaulcm)\
**Post date:** [July 27, 2018, 5:51am UTC](https://forum.ionicframework.com/t/ionic-v1-no-access-control-allow-origin/136366/3 "2018-07-27T05:51:18Z")

</div>

```auto
<access origin="*" /> 
<allow-navigation href="http://*/*" />
<allow-navigation href="https://*/*" />
<allow-navigation href="data:*" />

```

can you add the above lines in the config.xml and try

---

<div class="post-metadata">

**Author:** ![nicvr](https://avatars.discourse-cdn.com/v4/letter/n/ed8c4c/32.png) [@nicvr](https://forum.ionicframework.com/u/nicvr)\
**Post date:** [July 27, 2018, 6:54am UTC](https://forum.ionicframework.com/t/ionic-v1-no-access-control-allow-origin/136366/4 "2018-07-27T06:54:06Z")

</div>

@johnpaulcm @Youtch thanks for your reply.

@johnpaulcm I try your solution but nothing change.  
@Youtch your solution is ok for ionic serve, but i don’t use it, i edited the question.

---

<div class="post-metadata">

**Author:** ![joshmorony](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/joshmorony/32/117695_2.png) [@joshmorony](https://forum.ionicframework.com/u/joshmorony)\
**Post date:** [July 27, 2018, 7:09am UTC](https://forum.ionicframework.com/t/ionic-v1-no-access-control-allow-origin/136366/5 "2018-07-27T07:09:53Z")

</div>

The server you are making a request to should provide an `Access-Control-Allow-Origin` header that allows the origin you are making a request from, see: [https://enable-cors.org/server.html](https://enable-cors.org/server.html)

You may experience different behaviour between apps as UIWebView doesn’t enforce CORS, whereas WKWebView does. There are ways to workaround CORS, but the best solution is just for the server to provide the appropriate header.

---

<div class="post-metadata">

**Author:** ![nicvr](https://avatars.discourse-cdn.com/v4/letter/n/ed8c4c/32.png) [@nicvr](https://forum.ionicframework.com/u/nicvr)\
**Post date:** [July 27, 2018, 8:05am UTC](https://forum.ionicframework.com/t/ionic-v1-no-access-control-allow-origin/136366/6 "2018-07-27T08:05:03Z")

</div>

@joshmorony thanks for the input, for test i remove the cordova-plugin-ionic-webview (i have not look the documentation, it’s my fault) and the request works.

About the response header, often the simplest answer is the best, but I was stubborn on ‘it always works without…’

Just for curiosity, can u explain me links for workaround CORS (other than jsonp if exists)?

---

<div class="post-metadata">

**Author:** ![joshmorony](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/joshmorony/32/117695_2.png) [@joshmorony](https://forum.ionicframework.com/u/joshmorony)\
**Post date:** [July 27, 2018, 12:58pm UTC](https://forum.ionicframework.com/t/ionic-v1-no-access-control-allow-origin/136366/7 "2018-07-27T12:58:47Z")

</div>

Since UIWebView does not enforce CORS you can downgrade to that from WKWebView, but then you are sacrificing application performance just to workaround a permission issue. Another approach is to use the native HTTP plugin to send requests - this proxies the requests through native code so there is no issue with requesting from different web origins.

Again, it’s much better to just get the CORS issue sorted server side, but if you had to it would be better to do something like using native HTTP than downgrading to UIWebView.

---

<div class="post-metadata">

**Author:** ![nicvr](https://avatars.discourse-cdn.com/v4/letter/n/ed8c4c/32.png) [@nicvr](https://forum.ionicframework.com/u/nicvr)\
**Post date:** [August 1, 2018, 8:19am UTC](https://forum.ionicframework.com/t/ionic-v1-no-access-control-allow-origin/136366/8 "2018-08-01T08:19:28Z")

</div>

Thanks for the explanation!

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 19, 2021, 9:28pm UTC](https://forum.ionicframework.com/t/ionic-v1-no-access-control-allow-origin/136366/9 "2021-07-19T21:28:46Z")

</div>


