Spaces:
Running
Running
new contribute-repos
Browse files- app/api/auth/login-url/route.ts +1 -3
- app/api/auth/route.ts +1 -1
- components/domain-redirect/index.tsx +2 -2
- hooks/useEditor.ts +6 -12
app/api/auth/login-url/route.ts
CHANGED
|
@@ -6,8 +6,6 @@ export async function GET(req: NextRequest) {
|
|
| 6 |
let url: string;
|
| 7 |
if (host.includes("localhost")) {
|
| 8 |
url = host;
|
| 9 |
-
} else if (host.includes("hf.space") || host.includes("/spaces/enzostvs")) {
|
| 10 |
-
url = "enzostvs-deepsite.hf.space";
|
| 11 |
} else {
|
| 12 |
url = "huggingface.co/deepsite";
|
| 13 |
}
|
|
@@ -17,7 +15,7 @@ export async function GET(req: NextRequest) {
|
|
| 17 |
url +
|
| 18 |
"/deepsite/auth/callback";
|
| 19 |
|
| 20 |
-
const loginRedirectUrl = `https://huggingface.co/oauth/authorize?client_id=${process.env.OAUTH_CLIENT_ID}&redirect_uri=${redirect_uri}&response_type=code&scope=openid%20profile%
|
| 21 |
|
| 22 |
return NextResponse.json({ loginUrl: loginRedirectUrl });
|
| 23 |
}
|
|
|
|
| 6 |
let url: string;
|
| 7 |
if (host.includes("localhost")) {
|
| 8 |
url = host;
|
|
|
|
|
|
|
| 9 |
} else {
|
| 10 |
url = "huggingface.co/deepsite";
|
| 11 |
}
|
|
|
|
| 15 |
url +
|
| 16 |
"/deepsite/auth/callback";
|
| 17 |
|
| 18 |
+
const loginRedirectUrl = `https://huggingface.co/oauth/authorize?client_id=${process.env.OAUTH_CLIENT_ID}&redirect_uri=${redirect_uri}&response_type=code&scope=openid%20profile%20contribute-repos%20inference-api&prompt=consent&state=1234567890`;
|
| 19 |
|
| 20 |
return NextResponse.json({ loginUrl: loginRedirectUrl });
|
| 21 |
}
|
app/api/auth/route.ts
CHANGED
|
@@ -24,7 +24,7 @@ export async function POST(req: NextRequest) {
|
|
| 24 |
req.headers.get("host") ?? req.headers.get("origin") ?? "localhost:3000";
|
| 25 |
|
| 26 |
const url = host.includes("/spaces/enzostvs")
|
| 27 |
-
? "
|
| 28 |
: host;
|
| 29 |
const redirect_uri =
|
| 30 |
`${host.includes("localhost") ? "http://" : "https://"}` +
|
|
|
|
| 24 |
req.headers.get("host") ?? req.headers.get("origin") ?? "localhost:3000";
|
| 25 |
|
| 26 |
const url = host.includes("/spaces/enzostvs")
|
| 27 |
+
? "huggingface.co/deepsite"
|
| 28 |
: host;
|
| 29 |
const redirect_uri =
|
| 30 |
`${host.includes("localhost") ? "http://" : "https://"}` +
|
components/domain-redirect/index.tsx
CHANGED
|
@@ -14,8 +14,8 @@ export default function DomainRedirect() {
|
|
| 14 |
host === "huggingface.co" || host.startsWith("huggingface.co:");
|
| 15 |
|
| 16 |
if (!isHfCo && !isHuggingFaceCo) {
|
| 17 |
-
//
|
| 18 |
-
window.
|
| 19 |
}
|
| 20 |
}, []);
|
| 21 |
|
|
|
|
| 14 |
host === "huggingface.co" || host.startsWith("huggingface.co:");
|
| 15 |
|
| 16 |
if (!isHfCo && !isHuggingFaceCo) {
|
| 17 |
+
// Redirect to the correct URL
|
| 18 |
+
window.location.replace("https://huggingface.co/deepsite");
|
| 19 |
}
|
| 20 |
}, []);
|
| 21 |
|
hooks/useEditor.ts
CHANGED
|
@@ -215,22 +215,16 @@ export const useEditor = (namespace?: string, repoId?: string) => {
|
|
| 215 |
data.append("images", file); // Keep using "images" key for backward compatibility
|
| 216 |
});
|
| 217 |
|
| 218 |
-
const response = await
|
| 219 |
-
`/
|
| 220 |
-
|
| 221 |
-
method: "POST",
|
| 222 |
-
body: data,
|
| 223 |
-
headers: {
|
| 224 |
-
"Authorization": `Bearer ${token}`,
|
| 225 |
-
},
|
| 226 |
-
}
|
| 227 |
);
|
| 228 |
-
|
| 229 |
-
if (!response.ok) {
|
| 230 |
throw new Error('Upload failed');
|
| 231 |
}
|
| 232 |
|
| 233 |
-
return response.
|
| 234 |
},
|
| 235 |
onSuccess: (data) => {
|
| 236 |
setFiles((prev) => [...prev, ...data.uploadedFiles]);
|
|
|
|
| 215 |
data.append("images", file); // Keep using "images" key for backward compatibility
|
| 216 |
});
|
| 217 |
|
| 218 |
+
const response = await api.post(
|
| 219 |
+
`/me/projects/${project.space_id}/images`,
|
| 220 |
+
data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 221 |
);
|
| 222 |
+
|
| 223 |
+
if (!response.data.ok) {
|
| 224 |
throw new Error('Upload failed');
|
| 225 |
}
|
| 226 |
|
| 227 |
+
return response.data;
|
| 228 |
},
|
| 229 |
onSuccess: (data) => {
|
| 230 |
setFiles((prev) => [...prev, ...data.uploadedFiles]);
|