0

I have node service that runs on locahost and i am calling this service in HTML standalone page using ajax GET method. But this gives me no access control allow origin error please help

AJS
  • 953
  • 7
  • 21
  • Possible duplicate of [jQuery ajax request being block because Cross-Origin](https://stackoverflow.com/questions/31513450/jquery-ajax-request-being-block-because-cross-origin) – andolsi zied Dec 06 '17 at 16:48

1 Answers1

1

This question has already partially been answered here

If you Did write the API yourself, please add the following header to your API:

NodeJS:

app.use(function(req, res, next) {
  res.header('Access-Control-Allow-Origin', '*');
});

More detailed information can be find in the stack overflow question that has already been answered.

Kevin Vugts
  • 1,462
  • 4
  • 21
  • 39