Electron - 绕过 Sameorigin 中的 X 框架选项

Dar*_*mon 4 iframe electron

我试图在电子中显示一个网站,但出现错误,x-frame-option 位于同源,我已经阅读了很多关于如何绕过它的代码,但我不知道它放在哪里,如果在 main 中,或者在什么情况下,有人可以帮助我一点?链接是这个

https://mobile.bet365.com

dph*_*ans 7

初始化实例后使用以下行BrowserWindow

  win.webContents.session.webRequest.onHeadersReceived({ urls: [ "*://*/*" ] },
    (d, c)=>{
      if(d.responseHeaders['X-Frame-Options']){
        delete d.responseHeaders['X-Frame-Options'];
      } else if(d.responseHeaders['x-frame-options']) {
        delete d.responseHeaders['x-frame-options'];
      }

      c({cancel: false, responseHeaders: d.responseHeaders});
    }
  );
Run Code Online (Sandbox Code Playgroud)

但不推荐,只是为了测试目的而嵌入。