Dynamic Intelligence commited on
Commit
46f3967
·
1 Parent(s): 9b45fba

Fix 401 error: Add authenticated API proxy for private datasets

Browse files
src/app/[org]/[dataset]/[episode]/fetch-data.ts CHANGED
@@ -242,7 +242,7 @@ async function getEpisodeDataV2(
242
  try {
243
  const tasksUrl = buildVersionedUrl(repoId, version, "meta/tasks.jsonl");
244
  // Use proxy for authenticated requests
245
- const proxyUrl = buildProxyUrl(tasksUrl);
246
  const tasksResponse = await fetch(proxyUrl);
247
 
248
  if (tasksResponse.ok) {
 
242
  try {
243
  const tasksUrl = buildVersionedUrl(repoId, version, "meta/tasks.jsonl");
244
  // Use proxy for authenticated requests
245
+ const proxyUrl = await buildProxyUrl(tasksUrl);
246
  const tasksResponse = await fetch(proxyUrl);
247
 
248
  if (tasksResponse.ok) {
src/app/explore/page.tsx CHANGED
@@ -74,7 +74,7 @@ export default async function ExplorePage({
74
  const url = buildVersionedUrl(repoId, version, videoPath);
75
  // Check if videoUrl exists (status 200) - use proxy for authenticated requests
76
  try {
77
- const proxyUrl = buildProxyUrl(url);
78
  const headRes = await fetch(proxyUrl, { method: "HEAD" });
79
  if (headRes.ok) {
80
  videoUrl = url;
 
74
  const url = buildVersionedUrl(repoId, version, videoPath);
75
  // Check if videoUrl exists (status 200) - use proxy for authenticated requests
76
  try {
77
+ const proxyUrl = await buildProxyUrl(url);
78
  const headRes = await fetch(proxyUrl, { method: "HEAD" });
79
  if (headRes.ok) {
80
  videoUrl = url;
src/utils/parquetUtils.ts CHANGED
@@ -27,7 +27,7 @@ export interface DatasetMetadata {
27
 
28
  export async function fetchJson<T>(url: string): Promise<T> {
29
  // Use API proxy for authenticated requests (handles private repos)
30
- const proxyUrl = buildProxyUrl(url);
31
  const res = await fetch(proxyUrl);
32
  if (!res.ok) {
33
  const errorData = await res.json().catch(() => ({}));
@@ -48,7 +48,7 @@ export function formatStringWithVars(
48
  // Fetch and parse the Parquet file
49
  export async function fetchParquetFile(url: string): Promise<ArrayBuffer> {
50
  // Use API proxy for authenticated requests (handles private repos)
51
- const proxyUrl = buildProxyUrl(url);
52
  const res = await fetch(proxyUrl);
53
 
54
  if (!res.ok) {
 
27
 
28
  export async function fetchJson<T>(url: string): Promise<T> {
29
  // Use API proxy for authenticated requests (handles private repos)
30
+ const proxyUrl = await buildProxyUrl(url);
31
  const res = await fetch(proxyUrl);
32
  if (!res.ok) {
33
  const errorData = await res.json().catch(() => ({}));
 
48
  // Fetch and parse the Parquet file
49
  export async function fetchParquetFile(url: string): Promise<ArrayBuffer> {
50
  // Use API proxy for authenticated requests (handles private repos)
51
+ const proxyUrl = await buildProxyUrl(url);
52
  const res = await fetch(proxyUrl);
53
 
54
  if (!res.ok) {
src/utils/versionUtils.ts CHANGED
@@ -34,7 +34,7 @@ export async function getDatasetInfo(repoId: string): Promise<DatasetInfo> {
34
  const testUrl = `${DATASET_URL}/${repoId}/resolve/main/meta/info.json`;
35
 
36
  // Use API proxy for authenticated requests
37
- const proxyUrl = buildProxyUrl(testUrl);
38
 
39
  const controller = new AbortController();
40
  const timeoutId = setTimeout(() => controller.abort(), 10000); // 10 second timeout
 
34
  const testUrl = `${DATASET_URL}/${repoId}/resolve/main/meta/info.json`;
35
 
36
  // Use API proxy for authenticated requests
37
+ const proxyUrl = await buildProxyUrl(testUrl);
38
 
39
  const controller = new AbortController();
40
  const timeoutId = setTimeout(() => controller.abort(), 10000); // 10 second timeout