Spaces:
Running
Running
update
Browse files- app/api/auth/route.ts +0 -22
app/api/auth/route.ts
CHANGED
|
@@ -1,27 +1,5 @@
|
|
| 1 |
import { NextRequest, NextResponse } from "next/server";
|
| 2 |
|
| 3 |
-
export async function GET(req: NextRequest) {
|
| 4 |
-
const host = req.headers.get("host") ?? "localhost:3000";
|
| 5 |
-
|
| 6 |
-
const redirect_uri =
|
| 7 |
-
`${host.includes("localhost") ? "http://" : "https://"}` +
|
| 8 |
-
host +
|
| 9 |
-
"/auth/callback";
|
| 10 |
-
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`;
|
| 11 |
-
|
| 12 |
-
return NextResponse.json(
|
| 13 |
-
{
|
| 14 |
-
redirect: loginRedirectUrl,
|
| 15 |
-
},
|
| 16 |
-
{
|
| 17 |
-
status: 200,
|
| 18 |
-
headers: {
|
| 19 |
-
"Content-Type": "application/json",
|
| 20 |
-
},
|
| 21 |
-
}
|
| 22 |
-
);
|
| 23 |
-
}
|
| 24 |
-
|
| 25 |
export async function POST(req: NextRequest) {
|
| 26 |
const body = await req.json();
|
| 27 |
const { code } = body;
|
|
|
|
| 1 |
import { NextRequest, NextResponse } from "next/server";
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
export async function POST(req: NextRequest) {
|
| 4 |
const body = await req.json();
|
| 5 |
const { code } = body;
|