I am developing an application in IONIC
. I am making a $http.get
request in Angular JS and its giving me 404
error when I successfully login and trying to load the user profile using the token sent in the authentication header.
It produces error in chrome, although I enabled CORS
. Please check the screenshot:
Now if I try the url in POSTMAN
, everything is ok. See the screenshot below:
I am stuck with this error, can someone help me?
There are two ways to solve the issue: The first, and easier, solution is to just allow all origins from your API endpoint. However, we can’t always control the endpoint we are accessing. What we need, then, is a request that does not specify an origin.
We can do this by using a proxy server. Let’s look how the Ionic CLI provides
A simple solution is just add a CORS plugin into your browser and everything will work.
If you want a proxy server there is this tutorial: