feat: ship Wave 5-6 multi-surface hygiene, optimization, and bug fixes

This commit is contained in:
Yun Chan 2026-11-14 11:51:41 +09:00
parent 01ef3293cf
commit 66b6b45ba9
399 changed files with 17828 additions and 11330 deletions

View file

@ -1,40 +1,49 @@
// apps/admin/src/app/api/auth/logout/route.ts
// D3RO Voice — Admin Session Logout Handler
import { NextResponse } from 'next/server'
import { NextRequest, NextResponse } from 'next/server'
import { adminCookieSecure } from '@/lib/admin-session'
import { isSameOriginRequest } from '@/lib/request-security'
export async function POST(): Promise<NextResponse> {
const response = NextResponse.json({ success: true, message: 'Logged out successfully' })
function clearAdminSessionCookie(response: NextResponse): NextResponse {
response.cookies.set({
name: 'd3ro_admin_session',
value: '',
httpOnly: true,
secure: adminCookieSecure(),
sameSite: 'lax',
sameSite: 'strict',
path: '/',
maxAge: 0,
expires: new Date(0),
})
return response
}
export async function GET(request: Request): Promise<NextResponse> {
export async function POST(request: NextRequest): Promise<NextResponse> {
if (!isSameOriginRequest(request)) {
return NextResponse.json(
{ error: 'cross_site_request_rejected' },
{ status: 403, headers: { 'Cache-Control': 'no-store' } }
)
}
const response = NextResponse.json(
{ success: true, message: 'Logged out successfully' },
{ headers: { 'Cache-Control': 'no-store' } }
)
return clearAdminSessionCookie(response)
}
export async function GET(request: NextRequest): Promise<NextResponse> {
if (request.headers.get('sec-fetch-site') === 'cross-site') {
return NextResponse.json(
{ error: 'cross_site_request_rejected' },
{ status: 403, headers: { 'Cache-Control': 'no-store' } }
)
}
const url = new URL(request.url)
const response = NextResponse.redirect(new URL('/login', url.origin))
response.cookies.set({
name: 'd3ro_admin_session',
value: '',
httpOnly: true,
secure: adminCookieSecure(),
sameSite: 'lax',
path: '/',
maxAge: 0,
expires: new Date(0),
})
return response
response.headers.set('Cache-Control', 'no-store')
return clearAdminSessionCookie(response)
}