← back to Norma
app/api/auth/google/route.ts
26 lines
import { NextResponse } from 'next/server';
/**
* GET /api/auth/google
* Redirects the user to Google's OAuth2 consent screen.
*/
export async function GET() {
const clientId = process.env.GOOGLE_OAUTH_CLIENT_ID;
const redirectUri = process.env.GOOGLE_OAUTH_REDIRECT_URI || 'http://45.61.58.125:7400/api/auth/google/callback';
if (!clientId) {
return NextResponse.json({ error: 'Google OAuth not configured' }, { status: 500 });
}
const params = new URLSearchParams({
client_id: clientId,
redirect_uri: redirectUri,
response_type: 'code',
scope: 'openid email profile',
access_type: 'online',
prompt: 'select_account',
});
return NextResponse.redirect(`https://accounts.google.com/o/oauth2/v2/auth?${params.toString()}`);
}