Subsequently commited on
Commit
32b3f1b
·
verified ·
1 Parent(s): ab84502

Update setup-hf-config.mjs

Browse files
Files changed (1) hide show
  1. 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
- // Control UI flags required for HF Spaces iframe embedding
246
- config.gateway.controlUi = config.gateway.controlUi || {};
247
- config.gateway.controlUi.allowInsecureAuth = true;
248
- config.gateway.controlUi.allowedOrigins = ["*"];
249
- config.gateway.controlUi.dangerouslyDisableDeviceAuth = true;
250
- config.gateway.controlUi.dangerouslyAllowHostHeaderOriginFallback = true;
 
 
 
 
 
 
 
 
 
 
 
 
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;