谷歌浏览器插件 chrome.webRequest.onHeadersReceived 修改 无效问题


// web响应
chrome.webRequest.onHeadersReceived.addListener(
  (details) => {
    let responseHeaders = details.responseHeaders
    console.log('details', responseHeaders)
    let index = responseHeaders.findIndex((p) => p.name.toLowerCase() === 'x-frame-options')
    if (index > -1) {
      responseHeaders.splice(index, 1)
      console.log('删除 x-frame-options', responseHeaders)
    }

    return { responseHeaders }
  },
  { urls: ['<all_urls>'], types: ['main_frame', 'sub_frame'] },
  ['blocking', 'responseHeaders']
)
  

浏览器 f12 查看发现响应头 ,并没有变化,这时候  不要着急。  

 

把原本不允许 签入 iframe 的页面签入 进入 iframe 发现浏览器已经不报错了,至此就明白了,原来f12 查看到的响应头已经 失效了

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM