我尝试在meteor js中发送我的应用程序请求,当我发送它时,浏览器会显示以下消息: Origin:标题是必需的
发送时发生这种情况:http://crossorigin.me/https://scholar.google.cl/citations?user=n1qKMYwAAAAJ&hl=es
我正在使用CORS代理http://crossorigin.me/
如何设置此原始标题和位置?
感谢所有
答案 0 :(得分:0)
试试这段代码
app.use(function (req, res, next) {
// Website you wish to allow to connect
res.setHeader('Access-Control-Allow-Origin', '*');
// Request methods you wish to allow
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
// Request headers you wish to allow
res.setHeader('Access-Control-Allow-Headers', 'Content-Type,token');
//res.setHeader('*');
// Set to true if you need the website to include cookies in the requests sent
// to the API (e.g. in case you use sessions)
res.setHeader('Access-Control-Allow-Credentials', true);
// Pass to next layer of middleware
next();
});