-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroute.ts
More file actions
25 lines (21 loc) · 689 Bytes
/
route.ts
File metadata and controls
25 lines (21 loc) · 689 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { NextResponse } from "next/server";
import { cookies } from "next/headers";
import { logger } from "@/lib/logger";
export async function POST() {
try {
const cookieStore = await cookies(); // Add await here
const userId = cookieStore.get("userId")?.value;
if (userId) {
await logger.info("logout", {}, userId);
}
cookieStore.delete("userId");
return NextResponse.json({ message: "Logged out successfully" });
} catch (error) {
await logger.error("logout_error", { error: error.message });
console.error("Logout error:", error);
return NextResponse.json(
{ error: "Internal server error" },
{ status: 500 }
);
}
}