Handling CORS issues in Ionic2 [Solved]

#1

I want to use “ionic run -l android” so I can efficiently use livereload while hitting real Instagram API endpoints and I followed the spirit of the directions on this Ionic 1 post http://blog.ionic.io/handling-cors-issues-in-ionic/
but my proxy server returns HTTP 404.

I have an ionic.project file in root of my project with
{
“name”: “proxy-example”,
“app_id”: “”,
“proxies”: [
{
“path”: “/v1/”,
“proxyUrl”: “https://api.instagram.com/v1/
}
]
}

And my HTTP calls have been changed to this
http://192.168.0.4:8100/v1/users/self/?access_token=22369340xxxxxxxxxx

But the local proxy is returning HTTP 404 (Not Found).
I can see my app served from http://192.168.0.4:8100/ though.

So it looks like the ionic server is not recognizing my ionic.project file.

Here is my information:
Cordova CLI: 5.4.1
Ionic Version: 2.0.0-beta.0
Ionic CLI Version: 2.0.0-beta.17
Ionic App Lib Version: 2.0.0-beta.8
ios-deploy version: 1.8.4
ios-sim version: 2.0.1
OS: Mac OS X El Capitan
Node Version: v5.5.0
Xcode version: Xcode 7.1 Build version 7B91b

Do I need to do anything else to get the proxy to work with Ionic2?

#2


I got help from this thread. maciejkoch’s solution worked.

4 Likes
#3

Thank you, this works for me too! :smiley:

#4

I don’t have this file ionic.project file in my app. do i have to create it ? if yes, do i have to connect it with the app somehow ?

#5

Now, The ionic.project file is replaced with ionic.config.json file.

#6

Proxy setting work in browser correct manner but not working in android platform and ios paltform

#7

yeah me too i’m facing that issue in my application when i tried it in the mobile