File size: 767 Bytes
c6a6d00
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { NextResponse } from "next/server";

// HF Spaces auto-injects `window.huggingface.variables.OAUTH_CLIENT_ID` for
// static Spaces only. Docker Spaces (this one) just get OAUTH_CLIENT_ID /
// OAUTH_SCOPES as container env vars, so we surface them to the client via
// this endpoint. The client_id and scopes are public; the secret stays
// server-side and never leaves the proxy.

export const runtime = "nodejs";
export const dynamic = "force-dynamic";

export async function GET() {
  const clientId = process.env.OAUTH_CLIENT_ID;
  const scopes = process.env.OAUTH_SCOPES;
  if (!clientId) {
    return NextResponse.json({ enabled: false });
  }
  return NextResponse.json({
    enabled: true,
    clientId,
    scopes: scopes ?? "openid profile",
  });
}