fix: intercept on incoming requests to disable x-frame-options

pull/3437/head
Tienson Qin 2021-12-12 17:24:26 +08:00
parent 8bbca5d2ed
commit 32eba7ab7a
2 changed files with 22 additions and 1 deletions

View File

@ -15,7 +15,8 @@
["electron-window-state" :as windowStateKeeper]
[clojure.core.async :as async]
[electron.state :as state]
[electron.git :as git]))
[electron.git :as git]
["/electron/utils" :as utils]))
(defonce LSP_SCHEME "lsp")
(defonce LSP_PROTOCOL (str LSP_SCHEME "://"))
@ -295,6 +296,8 @@
*quitting? (atom false)]
(.. logger (info (str "Logseq App(" (.getVersion app) ") Starting... ")))
(utils/disableXFrameOptions win)
(when (search/version-changed?)
(search/rm-search-dir!))

View File

@ -0,0 +1,18 @@
// workaround from https://github.com/electron/electron/issues/426#issuecomment-658901422
// We set an intercept on incoming requests to disable x-frame-options
// headers.
export const disableXFrameOptions = (win) => {
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});
}
);
};