diff --git a/src/app/api/auth/login/route.ts b/src/app/api/auth/login/route.ts index 4414af2..262a7a1 100644 --- a/src/app/api/auth/login/route.ts +++ b/src/app/api/auth/login/route.ts @@ -1,6 +1,11 @@ -import {cookies} from 'next/headers'; +import {NextResponse} from 'next/server'; import type {NextRequest} from 'next/server'; import {verifyCredentials} from '@/features/auth/mock/users.mock'; +import { + LOGIN_ERROR_PARAM, + type LoginErrorCode, +} from '@/features/auth/services/loginErrorCodes'; +import {resolveRedirectTarget} from '@/features/auth/services/redirectTarget'; import { REMEMBERED_MAX_AGE_SECONDS, SESSION_COOKIE, @@ -25,6 +30,23 @@ export const dynamic = 'force-dynamic'; * • deciding how long the session lasts (rememberMe is a request, not an * instruction — the server sets the cookie lifetime) * • issuing the httpOnly cookie the client can never read or forge + * + * ── Two content types, one endpoint ────────────────────────────────────── + * It answers both `application/json` (the hydrated form, via authRepository) + * and `application/x-www-form-urlencoded` (the browser posting the form + * natively, before React has hydrated or when its bundle never arrived). + * + * That second path is not a nicety, it is the fix for a real leak. The sign-in + * form has named inputs; a