refactor: standardize session cookie configuration
Centralize cookie security options to dynamically detect HTTPS, ensure secure transport, and update client-side auth handlers to use explicit credential inclusion for cookie-based sessions.
This commit is contained in:
1 parent
fde2c86b1e
commit
b42029f67d
8 files changed
+80
-53
No files matched your search
@@ -1,15 +1,12 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { getSessionCookieOptions } from "@/core/auth/adminSession";
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
|
||||
const SESSION_COOKIE = "datastack_admin_session";
|
||||
|
||||
export async function POST() {
|
||||
export async function POST(request: NextRequest) {
|
||||
const response = NextResponse.json({ success: true });
|
||||
response.cookies.set(SESSION_COOKIE, "", {
|
||||
httpOnly: true,
|
||||
secure: process.env.NODE_ENV === "production",
|
||||
sameSite: "strict",
|
||||
path: "/",
|
||||
maxAge: 0,
|
||||
...getSessionCookieOptions(request, 0),
|
||||
expires: new Date(0),
|
||||
});
|
||||
return response;
|
||||
|
||||
Reference in new issue
Block a user