2

I have seen this question a lot on Stack Overflow with no explanation of it's meaning. Can someone explain what this error actually means?

Request header field Authentication is not allowed by Access-Control-Allow-Headers.

I am getting a strange error in my application.

If you open http://verse-pack.herokuapp.com/#/pack and click on the search I receive the error above.

However if you refresh the page from the search route(i.e http://verse-pack.herokuapp.com/#/search), no error occurs. Any help in understanding the problem or helping me overcome this problem would be appreciated! Thank you.

I am currently using a Node.js,Express.js,and Angular.js Stack.

Here is the code that is causing the error (API Key has been switched out)

$http.get("http://api.biblia.com/v1/bible/contents/LEB?key=abc123", {headers: {'Authentication': '*'}}).success(function(data) {
        console.log("What");
        $scope.tof = data;
    });
Kyle Copeland
  • 479
  • 1
  • 3
  • 14

2 Answers2

1

You're trying to do cross-domain scripting, which is disabled in most (if not all) browsers because it has security issues.

Workaround would be to enable CORS (or jsonp) on the server so that you can make those cross-domain calls. Please also keep in mind that this could result into security issues. (they didn't disable those requests in browsers without a reason)

Kurt Du Bois
  • 7,550
  • 4
  • 25
  • 33
1

You are calling "http://api.biblia.com/v1/bible/contents/LEB?key=777f34839f61b2c1097db13992d4cabc" from different domain. That will result cross-domain issue. You need to use JSONP request or ask "biblia.com" to accept cross-domain requests. I recommend to use "JSONP".

Hassan Siddique
  • 1,590
  • 14
  • 27
  • ! Thank you for the fast response. How do I wrap a JSON object in JSONP. I am getting Syntax errors now. There are no articles on google on how to wrap JSON objects in JSONP (only stack overflow questions). Thank you again for all your help! – Kyle Copeland Jan 29 '14 at 21:00
  • I have tried the following http://stackoverflow.com/questions/16344933/angularjs-jsonp-not-working/16352746#16352746. I get a 403 error. – Kyle Copeland Jan 29 '14 at 21:07