No ‘Access-Control-Allow-Origin’ in ajax request, but not by clicking on a <a> tag link

I am using HapiJS and Bell to authenticate users. I have an endPoint that is responsible to authenticate the users.

    method: ['POST','GET'],
    path: '/token',
    config: {
      auth: 'twitter',
      handler: function (request, reply) {



When I have an <a> tag link pointing to that endPoint everything works well, I am redirecting to twitter to authenticate and then I see the reply. What I want is to make that through ajax request so I can handle the response using then.

So I have something simple:

  method: 'GET',
  url: 'http://localhost:8001/token'

I click a button and I make the request, but in this case I have the following message on Chrome XMLHttpRequest cannot load No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. Any idea how can I solve that?

Source: ajax

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.