File size: 1,143 Bytes
250ae22 | 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 43 44 | // app/api/auth/me/route.ts
import { cookies } from 'next/headers';
import { NextRequest, NextResponse } from 'next/server';
export async function GET(request: NextRequest) {
try {
const cookieStore = await cookies();
const token = cookieStore.get('auth_token')?.value;
if (!token) {
return NextResponse.json(
{ message: 'Not authenticated' },
{ status: 401 }
);
}
const { searchParams } = new URL(request.url);
const userId = searchParams.get('userId');
const response = await fetch(
`https://byteriot-candidateexplorer.hf.space/CandidateExplorer/file/user/${userId}`,
{
headers: { Authorization: `Bearer ${token}` },
}
);
if (!response.ok) {
return NextResponse.json(
{ message: 'Invalid token' },
{ status: 401 }
);
}
const userData = await response.json();
return NextResponse.json(userData.files, { status: 200 });
} catch (error) {
console.error('Get list upload error:', error);
return NextResponse.json(
{ message: 'Failed to get list upload' },
{ status: 500 }
);
}
}
|