问题
Is it possible to disable the CORS checking functionality in the jsdom
node module?
The CORS errors are particularly difficult to debug in my use case (clientside testing) and do not occur in the actual environment I am running the program.
Perhaps some environmental variable we can set when initializing the object? e.g.,
window = new jsdom.JSDOM(``,{
cors : false,
}).window;
回答1:
As stated in this issue on JSDOM Github repository, JSDOM acts like a browser and the same-origin policy applies.
It cannot be disabled from there.
The solution would be to add headers to the resource server allowing the origin of the client which makes the request.
来源:https://stackoverflow.com/questions/49453445/disable-cors-checking-in-jsdom-on-nodejs