kalhdrawi's picture
Reupload OmniDev clean version
1e075e6
raw
history blame
842 Bytes
import { NextRequest, NextResponse } from "next/server";
export async function GET(req: NextRequest) {
const host = req.headers.get("host") ?? "localhost:3000";
const baseFromEnv = process.env.PUBLIC_BASE_URL?.trim();
const isLocal = (baseFromEnv || host).includes("localhost");
const protocol = isLocal ? "http" : "https";
const baseUrl = baseFromEnv || `${protocol}://${host}`;
const redirectPath = process.env.AUTH_REDIRECT_PATH || "/auth/callback";
const redirect_uri = `${baseUrl}${redirectPath}`;
const loginRedirectUrl = `https://huggingface.co/oauth/authorize?client_id=${process.env.OAUTH_CLIENT_ID}&redirect_uri=${redirect_uri}&response_type=code&scope=openid%20profile%20write-repos%20manage-repos%20inference-api&prompt=consent&state=1234567890`;
return NextResponse.json({ loginUrl: loginRedirectUrl });
}