diegonetto / generator-ionic

Build hybrid mobile apps using the Ionic Framework
MIT License
1.74k stars 336 forks source link

Proxy Support #214

Open tharrington opened 9 years ago

tharrington commented 9 years ago

I have node server running at localhost:9000 and I have setup a proxy in ionic.project:

{ "name": "myapp", "app_id": "", "proxies": [ { "path": "/api", "proxyUrl": "http://localhost:9000/api" } ] }

I have gotten user creation working through postman, but I am getting a CORS error in Ionic:

XMLHttpRequest cannot load http://localhost:9000/api/users. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8100' is therefore not allowed access. The response had HTTP status code 422. auth-service.js:25 data: null

Obviously this means that the proxy is not working, but after I run grunt serve I see ionic serve run and the console showing the added proxy:

Proxy added: /api => http://localhost:9000/api

What else must be done to proxy to my local server?

codegrean commented 9 years ago

@tharrington Did your change your hybrid app endpoint to Ionic:serve address (http://localhost:8100)?