import { NextResponse } from "next/server";

const PUBLIC_URL = process.env.PUBLIC_URL;

export async function GET() {
  if (!PUBLIC_URL) {
    return NextResponse.json({ error: "PUBLIC_URL not configured" }, { status: 500 });
  }

  // Static metadata - no database or OAuth client initialization needed
  const metadata = {
    client_name: "Sidetrail",
    client_id: `${PUBLIC_URL}/oauth-client-metadata.json`,
    client_uri: PUBLIC_URL,
    redirect_uris: [`${PUBLIC_URL}/oauth/callback`],
    scope: "atproto transition:generic",
    grant_types: ["authorization_code", "refresh_token"],
    response_types: ["code"],
    application_type: "web",
    token_endpoint_auth_method: "private_key_jwt",
    token_endpoint_auth_signing_alg: "ES256",
    dpop_bound_access_tokens: true,
    jwks_uri: `${PUBLIC_URL}/oauth/jwks.json`,
  };

  return NextResponse.json(metadata, {
    headers: {
      "Cache-Control": "public, max-age=300",
    },
  });
}
