Anuj sharma
Anuj sharma

Reputation: 123

On Developing Mobile app using ionic and web api 2.0

web api is hosted on secure server and i am accessing it through a path locally it is working fine. but after hosting an api
I am Getting this error while running an application

XMLHttpRequest cannot load https://xxxxx.xxxxapp.net/xxx_API/token. Response to preflight request doesn't pass access control check: 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 400.

Upvotes: 0

Views: 146

Answers (2)

Anas Omar
Anas Omar

Reputation: 504

try to put this in your ionic.project file

"proxies": [ { "path": "/api", "proxyUrl": "https://xxxxx.xxxxapp.net/xxx_API/token" } ] }

and change the proxuUrl with your api path

Upvotes: 0

Andrew
Andrew

Reputation: 1534

Well, your error give you an info about what to do. You are doing request with CORS (Cross-Origin Resource Sharing). It says that your request does not have Access-Control-Allow-Origin request header specified. So you should provide it. More about CORS

Upvotes: 0

Related Questions