2

I am connecting to a website via the following code using NodeJS:

request({
method: 'GET',
url: 'https://www.huffingtonpost.com/',
}, function(error, response, body) {
        if(error) {
            console.log(error);
        }
        huffpost(body);
   });

When I run the code from my html file using Browserify, I get the following error in my Javascript console:

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

I have seen other questions relating to this topic, and they all say to add a "header", but after looking for a while, I still don't understand.

Any and all help is appreciated, and I would be happy to provide any more info.

sideshowbarker
  • 81,827
  • 26
  • 193
  • 197
  • You can change your code to do `url: 'https://cors-anywhere.herokuapp.com/https://www.huffingtonpost.com/'`, and for an explanation, see the *How to use a CORS proxy to get around “No Access-Control-Allow-Origin header” problems* section of that answer at https://stackoverflow.com/a/43881141/441757 – sideshowbarker May 15 '19 at 02:42

0 Answers0