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:
Team Dark Devil committed 2026-11-16 22:12:48 +06:00
1 parent fde2c86b1e
commit b42029f67d
8 files changed
+80 -53

No files matched your search

+4 -7
View File
@@ -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;