Update setup-hf-config.mjs
Browse files- setup-hf-config.mjs +18 -6
setup-hf-config.mjs
CHANGED
|
@@ -242,12 +242,24 @@ function applyEnvPatches(config, tgToken) {
|
|
| 242 |
? { mode: "token", token: gatewayToken }
|
| 243 |
: { mode: "password", password: gatewayPassword };
|
| 244 |
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 251 |
|
| 252 |
// Always refresh trusted proxies (HF pod IPs can change)
|
| 253 |
config.gateway.trustedProxies = trustedProxies;
|
|
|
|
| 242 |
? { mode: "token", token: gatewayToken }
|
| 243 |
: { mode: "password", password: gatewayPassword };
|
| 244 |
|
| 245 |
+
// Control UI security configuration
|
| 246 |
+
config.gateway.controlUi = config.gateway.controlUi || {};
|
| 247 |
+
|
| 248 |
+
// Remove retired and unsafe legacy options
|
| 249 |
+
delete config.gateway.controlUi.dangerouslyDisableDeviceAuth;
|
| 250 |
+
delete config.gateway.controlUi.dangerouslyAllowHostHeaderOriginFallback;
|
| 251 |
+
|
| 252 |
+
// HTTPS is provided by Hugging Face Spaces
|
| 253 |
+
delete config.gateway.controlUi.allowInsecureAuth;
|
| 254 |
+
|
| 255 |
+
// Restrict browser origin to this Space
|
| 256 |
+
if (SPACE_HOST) {
|
| 257 |
+
config.gateway.controlUi.allowedOrigins = [
|
| 258 |
+
"https://" + SPACE_HOST
|
| 259 |
+
];
|
| 260 |
+
} else {
|
| 261 |
+
delete config.gateway.controlUi.allowedOrigins;
|
| 262 |
+
}
|
| 263 |
|
| 264 |
// Always refresh trusted proxies (HF pod IPs can change)
|
| 265 |
config.gateway.trustedProxies = trustedProxies;
|