Fixed the login again?

This commit is contained in:
2026-06-26 22:30:54 +02:00
parent cd37d5a987
commit 39fb39db12
5 changed files with 51 additions and 58 deletions
+9 -12
View File
@@ -1,22 +1,19 @@
import { NextResponse } from "next/server"
import { SESSION_COOKIE } from "@/lib/auth"
export async function POST() {
try {
const response = NextResponse.json({ success: true }, { status: 200 })
response.cookies.set(SESSION_COOKIE, "", {
httpOnly: true,
secure: process.env.NODE_ENV === "production",
sameSite: "strict",
path: "/",
maxAge: 0,
return new Response(JSON.stringify({ success: true }), {
status: 200,
headers: {
"Content-Type": "application/json",
"Set-Cookie": `${SESSION_COOKIE}=; HttpOnly; SameSite=Strict; Path=/; Max-Age=0`,
},
})
return response
} catch (error) {
console.error("Logout error:", error)
return NextResponse.json(
{ error: "Logout failed." },
{ status: 500 }
return new Response(
JSON.stringify({ error: "Logout failed." }),
{ status: 500, headers: { "Content-Type": "application/json" } }
)
}
}