route.js 954 B

1234567891011121314151617181920212223242526272829303132
  1. import { destroySession } from "@/lib/auth/session";
  2. import { withErrorHandling, json } from "@/lib/api/errors";
  3. /**
  4. * Next.js Route Handler caching configuration (RHL-006):
  5. *
  6. * We force this route to execute dynamically on every request.
  7. *
  8. * Reasons:
  9. * - NAS contents can change at any time (new scans).
  10. * - Auth/RBAC-protected responses must not be cached/shared across users.
  11. * - We rely on a small storage-layer TTL micro-cache instead of Next route caching.
  12. */
  13. export const dynamic = "force-dynamic";
  14. /**
  15. * GET /api/auth/logout
  16. *
  17. * Destroys the current session by clearing the auth cookie.
  18. * Always returns { ok: true } on success.
  19. *
  20. * Note:
  21. * - This endpoint is intentionally idempotent.
  22. * - If there is no cookie, destroySession() still sets an empty cookie.
  23. */
  24. export const GET = withErrorHandling(
  25. async function GET() {
  26. await destroySession();
  27. return json({ ok: true }, 200);
  28. },
  29. { logPrefix: "[api/auth/logout]" }
  30. );