File size: 981 Bytes
e394370 d635176 e394370 d635176 e394370 d635176 e394370 d635176 e394370 d635176 e394370 d635176 e394370 d635176 e394370 d635176 e394370 d635176 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | // app/api/auth/me/route.ts
import { cookies } from 'next/headers';
import { NextResponse } from 'next/server';
export async function GET() {
try {
const cookieStore = await cookies();
const token = cookieStore.get('auth_token')?.value;
if (!token) {
return NextResponse.json(
{ message: 'Not authenticated' },
{ status: 401 }
);
}
const response = await fetch(
'https://byteriot-candidateexplorer.hf.space/CandidateExplorer/admin/me',
{
headers: { Authorization: `Bearer ${token}` },
}
);
if (!response.ok) {
return NextResponse.json(
{ message: 'Invalid token' },
{ status: 401 }
);
}
const userData = await response.json();
return NextResponse.json(userData, { status: 200 });
} catch (error) {
console.error('Get user error:', error);
return NextResponse.json(
{ message: 'Failed to get user' },
{ status: 500 }
);
}
}
|