disable CORS checking in jsdom on nodejs

随声附和 提交于 2020-01-04 21:30:49

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!