Cross-origin request blocked, origin 'null' no access

别等时光非礼了梦想. 提交于 2019-12-24 10:59:53

问题


I'm working on a project where I want to get my calendar events through google API, written in JS and using React.

My question is why do I receive this error? I do receive my calendar events but beforehand this error pops up in the console of the web browser and I've tried it in firefox & chrome.

Chrome err: https://gyazo.com/bf7687b094c24d0027bcbd4071783b8c

Firefox err: https://gyazo.com/fa605bc75833d71070acbac34f1275da

This is how my app.js looks like: https://gyazo.com/f09b6906234c7d65b30ba4f40def1e50


回答1:


Some servers require auth key in the preflight OPTIONS request. Add the following line below your cors attachment:

app.use(cors());
app.options('*', cors());



回答2:


Check this Link It requires auth token in header to validate the request.

Also check this Post, its where i found above link.



来源:https://stackoverflow.com/questions/51836261/cross-origin-request-blocked-origin-null-no-access

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