Add src/app/api/admin/check-auth/route.ts

This commit is contained in:
2026-06-10 15:40:43 +00:00
parent 3e7fd3f25b
commit 85487b2fb1

View File

@@ -0,0 +1,14 @@
import { NextRequest, NextResponse } from 'next/server';
export async function GET(req: NextRequest) {
// In a real app, this would verify the JWT token from headers or session cookie.
// For this mock, we assume the middleware handled the primary check,
// or a client component sends a token to be verified.
const token = req.cookies.get('adminToken')?.value || req.headers.get('Authorization')?.split(' ')[1];
if (token === 'mock-admin-token') {
return NextResponse.json({ isAuthenticated: true, role: 'admin' }, { status: 200 });
} else {
return NextResponse.json({ isAuthenticated: false }, { status: 401 });
}
}