Download src/app/api/auth/google/route.ts from simikkk/test8: direct link, hf CLI and curl.
- Browser
- Download file 857 Bytes
-
https://huggingface.co/spaces/simikkk/test8/resolve/main/src/app/api/auth/google/route.ts
- Command line
-
hf download hf://spaces/simikkk/test8/src/app/api/auth/google/route.ts
-
curl -L -o route.ts https://huggingface.co/spaces/simikkk/test8/resolve/main/src/app/api/auth/google/route.ts
857 Bytes
| 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); |