Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions surfsense_web/lib/auth-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,9 @@ export async function logout(): Promise<boolean> {
clearAllTokens();

if (typeof window !== "undefined") {
// Rewrite "foss-<app>.<domain>" → "foss.<domain>" so we land on the portal
// (outside ForwardAuth) instead of SurfSense's own root, which would silently re-auth.
const portalHost = window.location.hostname.replace(/^[^.]*\./, "moneta.");
// Rewrite "<prefix>-<app>.<domain>" → "<prefix>.<domain>" so we land on the
// portal (outside ForwardAuth) instead of SurfSense's own root, which would silently re-auth.
const portalHost = window.location.hostname.replace(/^([^-]+)-[^.]+\.(.+)/, "$1.$2");
window.location.href = `${window.location.protocol}//${portalHost}`;
Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The redirect uses window.location.hostname (no port) and builds protocol//host, which drops any non-default port the app is running on. This can break setups where SurfSense is accessed via an explicit port (e.g. localhost:3000 / mapped Docker ports). Consider preserving window.location.port when present (or using window.location.host and rewriting just the hostname portion).

Suggested change
window.location.href = `${window.location.protocol}//${portalHost}`;
const portSuffix = window.location.port ? `:${window.location.port}` : "";
window.location.href = `${window.location.protocol}//${portalHost}${portSuffix}`;

Copilot uses AI. Check for mistakes.
return true;
}
Expand Down
Loading