enzostvs HF Staff commited on
Commit
4c9abd6
·
1 Parent(s): 33dc9ee

try login diff

Browse files
Files changed (2) hide show
  1. app/actions/auth.ts +4 -1
  2. app/api/auth/route.ts +5 -1
app/actions/auth.ts CHANGED
@@ -5,9 +5,12 @@ import { headers } from "next/headers";
5
  export async function getAuth() {
6
  const authList = await headers();
7
  const host = authList.get("host") ?? "localhost:3000";
 
 
 
8
  const redirect_uri =
9
  `${host.includes("localhost") ? "http://" : "https://"}` +
10
- host +
11
  "/auth/callback";
12
 
13
  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`;
 
5
  export async function getAuth() {
6
  const authList = await headers();
7
  const host = authList.get("host") ?? "localhost:3000";
8
+ const url = host.includes("/spaces/enzostvs")
9
+ ? "enzostvs-deepsite.hf.space"
10
+ : host;
11
  const redirect_uri =
12
  `${host.includes("localhost") ? "http://" : "https://"}` +
13
+ url +
14
  "/auth/callback";
15
 
16
  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`;
app/api/auth/route.ts CHANGED
@@ -22,9 +22,13 @@ export async function POST(req: NextRequest) {
22
 
23
  const host =
24
  req.headers.get("host") ?? req.headers.get("origin") ?? "localhost:3000";
 
 
 
 
25
  const redirect_uri =
26
  `${host.includes("localhost") ? "http://" : "https://"}` +
27
- host +
28
  "/auth/callback";
29
  const request_auth = await fetch("https://huggingface.co/oauth/token", {
30
  method: "POST",
 
22
 
23
  const host =
24
  req.headers.get("host") ?? req.headers.get("origin") ?? "localhost:3000";
25
+
26
+ const url = host.includes("/spaces/enzostvs")
27
+ ? "enzostvs-deepsite.hf.space"
28
+ : host;
29
  const redirect_uri =
30
  `${host.includes("localhost") ? "http://" : "https://"}` +
31
+ url +
32
  "/auth/callback";
33
  const request_auth = await fetch("https://huggingface.co/oauth/token", {
34
  method: "POST",