mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-09 03:37:45 +03:00
feat: removing session interception from auth
This commit is contained in:
parent
202751ddca
commit
586df616e8
@ -1,4 +1,4 @@
|
|||||||
import { app, BrowserWindow, net, protocol, session } from "electron";
|
import { app, BrowserWindow, net, protocol } from "electron";
|
||||||
import { init } from "@sentry/electron/main";
|
import { init } from "@sentry/electron/main";
|
||||||
import updater from "electron-updater";
|
import updater from "electron-updater";
|
||||||
import i18n from "i18next";
|
import i18n from "i18next";
|
||||||
@ -103,46 +103,6 @@ app.whenReady().then(async () => {
|
|||||||
|
|
||||||
WindowManager.createMainWindow();
|
WindowManager.createMainWindow();
|
||||||
WindowManager.createSystemTray(userPreferences?.language || "en");
|
WindowManager.createSystemTray(userPreferences?.language || "en");
|
||||||
|
|
||||||
session.defaultSession.webRequest.onBeforeSendHeaders((details, callback) => {
|
|
||||||
callback({
|
|
||||||
requestHeaders: {
|
|
||||||
...details.requestHeaders,
|
|
||||||
"user-agent":
|
|
||||||
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
session.defaultSession.webRequest.onHeadersReceived((details, callback) => {
|
|
||||||
const headers = {
|
|
||||||
"access-control-allow-origin": ["*"],
|
|
||||||
"access-control-allow-methods": ["GET, POST, PUT, DELETE, OPTIONS"],
|
|
||||||
"access-control-expose-headers": ["ETag"],
|
|
||||||
"access-control-allow-headers": [
|
|
||||||
"Content-Type, Authorization, X-Requested-With, If-None-Match",
|
|
||||||
],
|
|
||||||
"access-control-allow-credentials": ["true"],
|
|
||||||
};
|
|
||||||
|
|
||||||
if (details.method === "OPTIONS") {
|
|
||||||
callback({
|
|
||||||
cancel: false,
|
|
||||||
responseHeaders: {
|
|
||||||
...details.responseHeaders,
|
|
||||||
...headers,
|
|
||||||
},
|
|
||||||
statusLine: "HTTP/1.1 200 OK",
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
callback({
|
|
||||||
responseHeaders: {
|
|
||||||
...details.responseHeaders,
|
|
||||||
...headers,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
app.on("browser-window-created", (_, window) => {
|
app.on("browser-window-created", (_, window) => {
|
||||||
|
@ -61,6 +61,53 @@ export class WindowManager {
|
|||||||
show: false,
|
show: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.mainWindow.webContents.session.webRequest.onBeforeSendHeaders(
|
||||||
|
(details, callback) => {
|
||||||
|
callback({
|
||||||
|
requestHeaders: {
|
||||||
|
...details.requestHeaders,
|
||||||
|
"user-agent":
|
||||||
|
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
this.mainWindow.webContents.session.webRequest.onHeadersReceived(
|
||||||
|
(details, callback) => {
|
||||||
|
if (details.webContentsId !== this.mainWindow?.webContents.id) {
|
||||||
|
return callback(details);
|
||||||
|
}
|
||||||
|
|
||||||
|
const headers = {
|
||||||
|
"access-control-allow-origin": ["*"],
|
||||||
|
"access-control-allow-methods": ["GET, POST, PUT, DELETE, OPTIONS"],
|
||||||
|
"access-control-expose-headers": ["ETag"],
|
||||||
|
"access-control-allow-headers": [
|
||||||
|
"Content-Type, Authorization, X-Requested-With, If-None-Match",
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
if (details.method === "OPTIONS") {
|
||||||
|
return callback({
|
||||||
|
cancel: false,
|
||||||
|
responseHeaders: {
|
||||||
|
...details.responseHeaders,
|
||||||
|
...headers,
|
||||||
|
},
|
||||||
|
statusLine: "HTTP/1.1 200 OK",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return callback({
|
||||||
|
responseHeaders: {
|
||||||
|
...details.responseHeaders,
|
||||||
|
...headers,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
this.loadURL();
|
this.loadURL();
|
||||||
this.mainWindow.removeMenu();
|
this.mainWindow.removeMenu();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user