0

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!

user3340037
  • 661
  • 2
  • 8
  • 23

1 Answers1

2

Try adding this line

$httpProvider.defaults.useXDomain = true;
Alex J
  • 1,021
  • 6
  • 8
  • Ah, are you using Chrome by chance? If so, have you tried on other browsers? – Alex J Dec 22 '14 at 06:45
  • Yes I'm using chrome, anyway to fix it on chrome? Tried in firefox and same issue. – user3340037 Dec 22 '14 at 06:47
  • There's a known bug in Chrome http://stackoverflow.com/questions/21102690/angularjs-not-detecting-access-control-allow-origin-header, here's a solution to that http://stackoverflow.com/questions/3102819/disable-same-origin-policy-in-chrome – Alex J Dec 22 '14 at 06:49
  • Ah gotcha that's VERY helpful. But how is my app supposed to work in chrome at all then if I need to make an api call to access another resource? As in if it's in production it'd work? Just not local development? – user3340037 Dec 22 '14 at 06:52
  • http://stackoverflow.com/a/6083677/3421811 is the answer I think you're looking for – Alex J Dec 22 '14 at 06:54