Spaces:
Running
Running
fix(terminal): inject GATEWAY_TOKEN into JupyterLab proxy to skip double login prompt
Browse fileshealth-server.js reads JUPYTER_TOKEN at process start, but start_jupyter()
only exports it later — so the env var is empty and no auth header is
injected, causing JupyterLab to show its own login screen after the user
already authenticated with GATEWAY_TOKEN.
Fix: fall back to API_SERVER_KEY (== GATEWAY_TOKEN), which is exactly what
JupyterLab was started with. User authenticates once; no second prompt.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- health-server.js +5 -1
health-server.js
CHANGED
|
@@ -950,7 +950,11 @@ const server = http.createServer(async (req, res) => {
|
|
| 950 |
}
|
| 951 |
// Inject the Jupyter token so JupyterLab skips its own login screen.
|
| 952 |
// User already authenticated via GATEWAY_TOKEN — no second prompt needed.
|
| 953 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 954 |
const overrides = jToken ? { authorization: `token ${jToken}` } : {};
|
| 955 |
proxyRequest(req, res, JUPYTER_PORT, (p) => p, overrides);
|
| 956 |
});
|
|
|
|
| 950 |
}
|
| 951 |
// Inject the Jupyter token so JupyterLab skips its own login screen.
|
| 952 |
// User already authenticated via GATEWAY_TOKEN — no second prompt needed.
|
| 953 |
+
// JUPYTER_TOKEN env may be empty in this process (health-server starts before
|
| 954 |
+
// start_jupyter() exports it), so fall back to API_SERVER_KEY (== GATEWAY_TOKEN),
|
| 955 |
+
// which is what JupyterLab was actually started with.
|
| 956 |
+
const rawJToken = (process.env.JUPYTER_TOKEN || "").trim();
|
| 957 |
+
const jToken = rawJToken || API_SERVER_KEY;
|
| 958 |
const overrides = jToken ? { authorization: `token ${jToken}` } : {};
|
| 959 |
proxyRequest(req, res, JUPYTER_PORT, (p) => p, overrides);
|
| 960 |
});
|