Update route.ts
This commit is contained in:
@@ -26,6 +26,7 @@ export async function GET(req: NextRequest) {
|
||||
const apiUrl = process.env.SERVER_API_URL || 'https://internal-api.inboxi.ng/api';
|
||||
console.log(`Auth check: Calling external API: ${apiUrl}/auth/me`);
|
||||
|
||||
try {
|
||||
const res = await fetch(`${apiUrl}/auth/me`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
@@ -63,7 +64,16 @@ export async function GET(req: NextRequest) {
|
||||
const data = await res.json();
|
||||
console.log('Auth check succeeded:', { userId: data._id || 'unknown' });
|
||||
return NextResponse.json(data);
|
||||
|
||||
} catch (fetchError) {
|
||||
console.error('Auth check network error:', fetchError);
|
||||
return NextResponse.json(
|
||||
{
|
||||
error: 'Failed to connect to authentication service',
|
||||
details: fetchError instanceof Error ? fetchError.message : String(fetchError)
|
||||
},
|
||||
{ status: 503 } // Service Unavailable
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Auth check error:', error);
|
||||
return NextResponse.json(
|
||||
|
||||
Reference in New Issue
Block a user