3
                            在路由函数中测试过下面两段代码,浏览器返回的还是 X-Frame-Options: SAMEORIGIN,请问如何修改才能生效呢?
this.ctx.set(
  'x-frame-options',
  'ALLOWALL'
)和
const { response } = this.ctx
response.headers['x-frame-options'] = 'ALLOWALL'在路由函数中测试过下面两段代码,浏览器返回的还是 X-Frame-Options: SAMEORIGIN,请问如何修改才能生效呢?
this.ctx.set(
  'x-frame-options',
  'ALLOWALL'
)和
const { response } = this.ctx
response.headers['x-frame-options'] = 'ALLOWALL'是不是被 egg-securtiy 里面的覆盖掉了?
没安装 egg-securtiy,不存在被它覆盖的可能
我的 package.json 里有 egg-cors,但是没有 egg-securtiy
我看到 node_modules/egg-securtiy 存在,是否是安装 egg-cors 的时候带来的,那么就有点尴尬了,我怎么覆盖 egg-securtiy 呢
config.security = {
    xframe: {
      value: 'SAMEORIGIN',
      ignore: '/xxx',
    }
}加上这段之后,生效了。
egg-securtiy 是内置能力
@atian25 提个建议,配置 ignore 其实挺难看的,比如我有多个路由映射到一个controller,按照现在的写法,我得把所有路由配置在这,以后如果再加一个路由映射,我还得记得回来改这里。
如果可以在 controller 函数直接一行代码手动设置,就避免了问题。
https://github.com/eggjs/egg-security/blob/master/lib/middlewares/xframe.js
在洋葱模型的后段设置的,除非这里判断有没有手动设置过,但会有点不优雅和麻烦。
一般也不会经常需要单独设置多个规则吧,大部分都是全局的。
ignore 和 match 是可以数组或函数的。