route.js 551 B

1234567891011121314151617181920
  1. import { destroySession } from "@/lib/auth/session";
  2. import { withErrorHandling, json } from "@/lib/api/errors";
  3. /**
  4. * GET /api/auth/logout
  5. *
  6. * Destroys the current session by clearing the auth cookie.
  7. * Always returns { ok: true } on success.
  8. *
  9. * Note:
  10. * - This endpoint is intentionally idempotent.
  11. * - If there is no cookie, destroySession() still sets an empty cookie.
  12. */
  13. export const GET = withErrorHandling(
  14. async function GET() {
  15. await destroySession();
  16. return json({ ok: true }, 200);
  17. },
  18. { logPrefix: "[api/auth/logout]" }
  19. );