mirror of
https://gitlab.w-hs.de/an14051/backerup-website.git
synced 2026-07-27 17:35:29 +00:00
feat: enhance session management by adding secure cookie handling based on HTTPS detection
This commit is contained in:
@@ -86,6 +86,13 @@ export async function POST(request: Request) {
|
||||
}
|
||||
|
||||
clearAttempts(ip)
|
||||
await createSession({ userId: user.id, username: user.username, role: user.role })
|
||||
|
||||
// Detect whether the client is on HTTPS (via reverse-proxy header or direct TLS).
|
||||
// CasaOS and most self-hosted setups run over plain HTTP, so the cookie must
|
||||
// NOT be marked Secure or the browser will silently drop it.
|
||||
const proto = request.headers.get('x-forwarded-proto') ?? ''
|
||||
const isHttps = proto.split(',')[0].trim() === 'https'
|
||||
|
||||
await createSession({ userId: user.id, username: user.username, role: user.role }, isHttps)
|
||||
return NextResponse.json({ ok: true, username: user.username, role: user.role })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user