Nodejs X-Frame-Options 响应头设置

1. const frameguard = require('frameguard')

// // Don't allow me to be in ANY frames:
// app.use(frameguard({ action: 'deny' }))

// // Only let me be framed by people of the same origin:
// app.use(frameguard({ action: 'sameorigin' }))
// app.use(frameguard())  // defaults to sameorigin

// Allow from a specific host:
app.use(frameguard({
  action: 'allow-from',
  domain: 'https://www.baidu.com'
}))

2. 直接使用helmet

const helmet = require('helmet')

app.use(helmet({
  frameguard: false  // 允许iframe
}))

你可能感兴趣的:(node,express,X-Frame-Options)