| import { NextRequest, NextResponse } from 'next/server'; |
| import { withDb } from '@/lib/api-handler'; |
|
|
| async function handler(_request: NextRequest) { |
| const clientId = process.env.GOOGLE_CLIENT_ID; |
|
|
| if (!clientId) { |
| return NextResponse.json({ enabled: false }); |
| } |
|
|
| const redirectUri = `${process.env.NEXT_PUBLIC_BASE_URL || ''}/api/auth/google/callback`; |
|
|
| const url = new URL('https://accounts.google.com/o/oauth2/v2/auth'); |
| url.searchParams.set('client_id', clientId); |
| url.searchParams.set('redirect_uri', redirectUri); |
| url.searchParams.set('response_type', 'code'); |
| url.searchParams.set('scope', 'openid email profile'); |
| url.searchParams.set('access_type', 'offline'); |
| url.searchParams.set('prompt', 'consent'); |
|
|
| return NextResponse.json({ |
| enabled: true, |
| url: url.toString(), |
| }); |
| } |
|
|
| export const GET = withDb(handler); |