简体   繁体   中英

How NodeJS app access resources from a disabled CORS(Cross Origin Sharing) Server using HTTP requests?

I am aware that there's a need in server side to enable CORS so as clients can access server resources programmatically. Otherwise the client request will result to blocked by CORS policy: No 'Access-Control-Allow-Origin'

I was trying to make a Scraper in client side using 2 ways, First is jQuery and NodeJS App(using Request Library). Note: the website that I am going to access has DISABLED their CORS.

When I tested it the responses are:

jQuery -> blocked by CORS policy: No 'Access-Control-Allow-Origin'

NodeJS App -> Status OK 200 and I was able to scrape.

How NodeJS app access resources from a disabled CORS(Cross Origin Sharing) Server using HTTP requests?

I am wondering is it because of V8 engine act as a browser when NodeJS send request?

CORS is just an agreement that browsers follow. It doesn't apply to back-end servers like your nodejs app.

https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM