I have a CORS problem when I try to do a request to an external API. I tried to add the token to all requests like this:
var dApp = angular.module("app", []);
dApp.run(function($http) {
$http.defaults.headers.common.Authorization = 'APP token=TOKEN';
});
The Authorization
string is defined as defined on API.
If I check the headers of the request I can't see my string and the return code is 404 OPTIONS
.
I tried to do the request with Postman and it works.
It returns 404 but the error in the console is:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.discogs.com/database/search?type=master&artist=The%20Strokes&format=album&callback=. (Reason: CORS header 'Access-Control-Allow-Origin' missing).
If I pass the token on the url it works, but only with GET and POST requests.
I already read the question Angular.js performs an options http request for CORS resource but I didn't found the solution for my problem