我一次又一次地得到同样的错误。我已将头盔用于X-Frame-Options,而其他标头则使用access-allow。在firefox控制台显示" X-Frame-Options拒绝加载:不允许框架。"在Chrome控制台显示"拒绝在框架中显示,因为它设置了X-Frame-Options' to' sameorigin'。" 请给我一些解决方案。任何建议将不胜感激。 这是代码:
var app = express();
var helmet = require('helmet');
app.use(helmet({
frameguard: {
action: 'allow-from',
domain: 'https://calendar.google.com/calendar/'
}
}))
var enableCORS = function(req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
res.header('Access-Control-Allow-Headers', 'Content-Type, token, Content-Length, X-Requested-With, *');
if ('OPTIONS' === req.method) {
res.sendStatus(200);
} else {
next();
}
};
app.all("/*", function(req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
res.header('Access-Control-Allow-Headers', 'Content-Type, token, Content-Length, X-Requested-With, *');
// res.set('X-Frame-Options', 'ALLOW-FROM htps://google.com/');
next();
});
app.use(enableCORS);
答案 0 :(得分:0)
您的配置恰恰相反:
X-Frame-Options
允许https://calendar.google.com/calendar/将您的页面放入iframe中。
某些网站不允许其他网站构建其内容,这就是您收到错误的原因,因为如果https://calendar.google.com/calendar/将DENY
设置为SAMEORIGIN
,ALLOW-FROM http://example.com
或{{1} } http://example.com与您的其他域名不同,您无法构建任何https://calendar.google.com/calendar/内容。