Fix: Add HF_TOKEN to explore page fetch calls for 401 error
Browse files- src/app/explore/page.tsx +11 -1
src/app/explore/page.tsx
CHANGED
|
@@ -7,6 +7,16 @@ import {
|
|
| 7 |
} from "@/utils/parquetUtils";
|
| 8 |
import { getDatasetVersion, buildVersionedUrl } from "@/utils/versionUtils";
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
export default async function ExplorePage({
|
| 11 |
searchParams,
|
| 12 |
}: {
|
|
@@ -73,7 +83,7 @@ export default async function ExplorePage({
|
|
| 73 |
const url = buildVersionedUrl(repoId, version, videoPath);
|
| 74 |
// Check if videoUrl exists (status 200)
|
| 75 |
try {
|
| 76 |
-
|
| 77 |
if (headRes.ok) {
|
| 78 |
videoUrl = url;
|
| 79 |
}
|
|
|
|
| 7 |
} from "@/utils/parquetUtils";
|
| 8 |
import { getDatasetVersion, buildVersionedUrl } from "@/utils/versionUtils";
|
| 9 |
|
| 10 |
+
// Get token from environment (set in Space secrets)
|
| 11 |
+
const hfToken = process.env.HF_TOKEN;
|
| 12 |
+
const getHeaders = () => {
|
| 13 |
+
const headers: HeadersInit = {};
|
| 14 |
+
if (hfToken) {
|
| 15 |
+
headers["Authorization"] = `Bearer ${hfToken}`;
|
| 16 |
+
}
|
| 17 |
+
return headers;
|
| 18 |
+
};
|
| 19 |
+
|
| 20 |
export default async function ExplorePage({
|
| 21 |
searchParams,
|
| 22 |
}: {
|
|
|
|
| 83 |
const url = buildVersionedUrl(repoId, version, videoPath);
|
| 84 |
// Check if videoUrl exists (status 200)
|
| 85 |
try {
|
| 86 |
+
const headRes = await fetch(url, { method: "HEAD", headers: getHeaders() });
|
| 87 |
if (headRes.ok) {
|
| 88 |
videoUrl = url;
|
| 89 |
}
|