Abid Ali Awan Codex commited on
Commit ·
db68987
1
Parent(s): 429a368
Fix ZeroGPU quota: add x-ip-token handshake for HF iframe
Browse filesgr.Server custom frontends don't perform the postMessage handshake
with the HF parent iframe, so the @gradio/client JS never fetches
the x-ip-token. All requests are treated as unauthenticated (IP-
based ~2 min quota) regardless of login or PRO status.
Add the handshake from Gradio's Svelte frontend (Index.svelte) so
logged-in users get their proper quota applied.
Fixes gradio-app/gradio#13209
Co-authored-by: Codex <codex@openai.com>
- static/index.html +17 -0
static/index.html
CHANGED
|
@@ -8,6 +8,23 @@
|
|
| 8 |
<title>NoticeCheck</title>
|
| 9 |
<link rel="icon" href="/static/mark.svg" type="image/svg+xml">
|
| 10 |
<link rel="stylesheet" href="/static/styles.css">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
<script src="/static/app.js" defer></script>
|
| 12 |
</head>
|
| 13 |
<body>
|
|
|
|
| 8 |
<title>NoticeCheck</title>
|
| 9 |
<link rel="icon" href="/static/mark.svg" type="image/svg+xml">
|
| 10 |
<link rel="stylesheet" href="/static/styles.css">
|
| 11 |
+
<script>
|
| 12 |
+
// ZeroGPU auth handshake — required for PRO quota in HF iframe.
|
| 13 |
+
// Without this, gr.Server custom frontends are treated as unauthenticated.
|
| 14 |
+
const ZEROGPU_HEADERS_MSG = "supports-zerogpu-headers";
|
| 15 |
+
window.addEventListener("message", (event) => {
|
| 16 |
+
if (event.data === ZEROGPU_HEADERS_MSG) {
|
| 17 |
+
window.supports_zerogpu_headers = true;
|
| 18 |
+
}
|
| 19 |
+
});
|
| 20 |
+
const hostname = window.location.hostname;
|
| 21 |
+
if (hostname.endsWith(".hf.space") || hostname.includes(".dev.")) {
|
| 22 |
+
const origin = hostname.includes(".dev.")
|
| 23 |
+
? `https://moon-${hostname.split(".")[1]}.dev.spaces.huggingface.tech`
|
| 24 |
+
: "https://huggingface.co";
|
| 25 |
+
window.parent.postMessage(ZEROGPU_HEADERS_MSG, origin);
|
| 26 |
+
}
|
| 27 |
+
</script>
|
| 28 |
<script src="/static/app.js" defer></script>
|
| 29 |
</head>
|
| 30 |
<body>
|