fix(auth): Sitzungs-Cookie auch ueber http nutzbar, Anmeldung als Formular (#013)

Das Cookie erhielt im Produktionsbau immer Secure und wurde ueber http vom
Browser verworfen – nach der Anmeldung landete jeder Klick wieder auf der
Anmeldeseite. Massgeblich ist jetzt das Schema in APP_URL.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-17 23:41:01 +02:00
co-authored by Claude Opus 5
parent f838a44991
commit 2c2f842d20
31 changed files with 277 additions and 69 deletions
+12 -1
View File
@@ -53,11 +53,22 @@ export async function sitzungLesen(token: string | undefined): Promise<Sitzung |
}
}
/**
* `Secure` richtet sich nach der tatsächlichen Adresse, nicht nach NODE_ENV:
* Ein produktiv gebautes Dashboard, das über http:// läuft (etwa im LAN oder beim lokalen Prüfen),
* würde sonst ein Cookie setzen, das der Browser verwirft – die Anmeldung liefe dann ins Leere.
*/
export function ueberHttps(): boolean {
const adresse = process.env.APP_URL;
if (adresse) return adresse.startsWith("https://");
return process.env.NODE_ENV === "production";
}
export function cookieOptionen() {
return {
httpOnly: true,
sameSite: "lax" as const,
secure: process.env.NODE_ENV === "production",
secure: ueberHttps(),
path: "/",
maxAge: SITZUNGSDAUER_STUNDEN * 3600,
};