Updated token usage

This commit is contained in:
Florian Rappl
2026-06-22 23:23:44 +02:00
parent 773937448d
commit 94ff3c1c4d
3 changed files with 32 additions and 5 deletions

View File

@@ -280,8 +280,20 @@ module.exports = (socket, app) => {
// Append authentication token to initial URL if available
const token = global["authToken"];
if (token) {
const separator = loadUrl.includes("?") ? "&" : "?";
window.loadURL(`${loadUrl}${separator}token=${token}`);
try {
const url = new URL(loadUrl);
const isLocal = url.hostname === "localhost" ||
url.hostname === "127.0.0.1" ||
url.hostname === "::1";
if (isLocal) {
url.searchParams.set("token", token);
}
window.loadURL(url.toString());
}
catch {
// Handle invalid URLs or file:// URLs if needed
window.loadURL(loadUrl);
}
}
else {
window.loadURL(loadUrl);

File diff suppressed because one or more lines are too long

View File

@@ -313,8 +313,23 @@ export = (socket: Socket, app: Electron.App) => {
const token = global["authToken"];
if (token) {
const separator = loadUrl.includes("?") ? "&" : "?";
window.loadURL(`${loadUrl}${separator}token=${token}`);
try {
const url = new URL(loadUrl);
const isLocal =
url.hostname === "localhost" ||
url.hostname === "127.0.0.1" ||
url.hostname === "::1";
if (isLocal) {
url.searchParams.set("token", token);
}
window.loadURL(url.toString());
} catch {
// Handle invalid URLs or file:// URLs if needed
window.loadURL(loadUrl);
}
} else {
window.loadURL(loadUrl);
}