route.js 611 B

1234567891011121314151617181920212223242526272829
  1. import { destroySession } from "@/lib/auth/session";
  2. /**
  3. * GET /api/auth/logout
  4. *
  5. * Destroys the current session by clearing the auth cookie.
  6. * Always returns { ok: true } on success.
  7. */
  8. export async function GET() {
  9. try {
  10. destroySession();
  11. return new Response(JSON.stringify({ ok: true }), {
  12. status: 200,
  13. headers: {
  14. "Content-Type": "application/json",
  15. },
  16. });
  17. } catch (error) {
  18. console.error("Logout error:", error);
  19. return new Response(JSON.stringify({ error: "Internal server error" }), {
  20. status: 500,
  21. headers: {
  22. "Content-Type": "application/json",
  23. },
  24. });
  25. }
  26. }