假设我已经在域中获得授权并参加boo.com
了这次会议:
s:x2GYrvxGgmsfFwx7gDbKXmwB.4BDXLpMaSqD9hgeTkBDx3z4TeczJeC50gnrH5bc+kWU
我想要的是将脚本标签添加到domain foo.com
,指向boo.com
:
<script src='http://boo.com/blah.js'></script>
在包括Safari和Google Chrome在内的所有浏览器中,script标签都在HTTP标头中设置cookie值,但在Firefox中不起作用。
Firefox没有设置Cookie标头,因此我Unauthorized
从服务器收到错误消息。问题是什么?
更新:
我在服务器端启用了CORS,但该问题在Firefox中仍然存在:
app.use(function (req, res, next) {
// Website you wish to allow to connect
res.setHeader('Access-Control-Allow-Origin', 'http://foo.com');
// 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', 'Cookie');
// 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();
});
我发现了问题。由于我的Firefox不接受第三方cookie,因此该script
标记和来自其他域的所有其他http请求都不共享该cookie。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句