user3340037
user3340037

Reputation: 731

CORS issue with angular http request

I'm trying to access the results from a pocket API call which requires posting to their domain. However, when I post, I get the issue

XMLHttpRequest cannot load https://getpocket.com/v3/get. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'localhost:3000' is therefore not allowed access. The response had HTTP status code 406.

However, I've configured the httpProvider options to such.

$httpProvider.defaults.useXDomain = true;
$httpProvider.defaults.withCredentials = true;
delete $httpProvider.defaults.headers.common["X-Requested-With"];
$httpProvider.defaults.headers.common["Accept"] = "application/json";
$httpProvider.defaults.headers.common["Content-Type"] = "application/json";

I thought the configurations would allow the request to proceed, but they don't. I need a post request, so jsonp won't work. Any ideas would be much appreciated!

Upvotes: 0

Views: 488

Answers (1)

Alex J
Alex J

Reputation: 1019

Try adding this line

$httpProvider.defaults.useXDomain = true;

Upvotes: 2

Related Questions