Besjon Cifliku commited on
Commit
f930251
·
1 Parent(s): 8042dc1

fix: _sign request on hf spaces

Browse files
Files changed (1) hide show
  1. frontend/src/api.ts +9 -1
frontend/src/api.ts CHANGED
@@ -11,7 +11,15 @@ import type {
11
  ContextAnalysisResponse,
12
  } from "./types";
13
 
14
- const client = axios.create({ baseURL: "/api" });
 
 
 
 
 
 
 
 
15
  const long = { timeout: 600000 };
16
 
17
  /** Extract a human-readable error message from an Axios error. */
 
11
  ContextAnalysisResponse,
12
  } from "./types";
13
 
14
+ // HuggingFace Spaces proxy requires the __sign token on every request.
15
+ // Extract it from the page URL and attach to all API calls.
16
+ const _params = new URLSearchParams(window.location.search);
17
+ const _sign = _params.get("__sign");
18
+
19
+ const client = axios.create({
20
+ baseURL: "/api",
21
+ ...(_sign && { params: { __sign: _sign } }),
22
+ });
23
  const long = { timeout: 600000 };
24
 
25
  /** Extract a human-readable error message from an Axios error. */