| 123456789101112131415161718192021222324252627282930 |
- // app/api/auth/logout/route.js
- import { destroySession } from "@/lib/auth/session";
- /**
- * GET /api/auth/logout
- *
- * Destroys the current session by clearing the auth cookie.
- * Always returns { ok: true } on success.
- */
- export async function GET() {
- try {
- await destroySession();
- return new Response(JSON.stringify({ ok: true }), {
- status: 200,
- headers: {
- "Content-Type": "application/json",
- },
- });
- } catch (error) {
- console.error("Logout error:", error);
- return new Response(JSON.stringify({ error: "Internal server error" }), {
- status: 500,
- headers: {
- "Content-Type": "application/json",
- },
- });
- }
- }
|