我有一些静态资源,希望在多个桌面/移动网络客户端的iframe中提供服务。
现在,如何白名单特定集合的来源,以允许设置X-Frame-Options头文件,从而可以嵌入不同桌面/移动网络客户端的资源, 并拒绝所有其他来源访问此资源。
通过一点挖掘,我开始使用 -
const app = express();
var allowCrossDomain = 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, X-Requested-With, Authorization');
if (req.method === "OPTIONS") res.send(200);
else next();
}
app.use(allowCrossDomain);
现在,我该如何使用白名单中的来源值设置X-Frame-Options标头 -