This commit is contained in:
Shreyaschorge
2025-07-15 21:38:47 +05:30
parent b366d97b53
commit 378ea65154
8 changed files with 57 additions and 55 deletions

View File

@@ -8,15 +8,12 @@ export async function POST(request: Request) {
const { token } = await request.json();
if (!token) {
return NextResponse.json(
{ error: 'Token is required' },
{ status: 400 }
);
return NextResponse.json({ error: 'Token is required' }, { status: 400 });
}
// Get domain from environment or request
const domain = process.env.NEXT_PUBLIC_URL
? new URL(process.env.NEXT_PUBLIC_URL).hostname
const domain = process.env.NEXT_PUBLIC_URL
? new URL(process.env.NEXT_PUBLIC_URL).hostname
: request.headers.get('host') || 'localhost';
try {
@@ -35,10 +32,7 @@ export async function POST(request: Request) {
} catch (e) {
if (e instanceof Errors.InvalidTokenError) {
console.info('Invalid token:', e.message);
return NextResponse.json(
{ error: 'Invalid token' },
{ status: 401 }
);
return NextResponse.json({ error: 'Invalid token' }, { status: 401 });
}
throw e;
}
@@ -46,7 +40,7 @@ export async function POST(request: Request) {
console.error('Token validation error:', error);
return NextResponse.json(
{ error: 'Internal server error' },
{ status: 500 }
{ status: 500 },
);
}
}
}