Logankunfall commited on
Commit
a05a0c6
·
verified ·
1 Parent(s): 27362f1

Upload 10 files

Browse files
Files changed (1) hide show
  1. server.js +11 -2
server.js CHANGED
@@ -50,11 +50,14 @@ const FORCE_MINIMAL = /^true$/i.test(process.env.FORCE_MINIMAL || 'false');
50
 
51
  // Middlewares
52
  app.use(helmet({
53
- crossOriginResourcePolicy: { policy: 'cross-origin' }
 
 
54
  }));
55
 
56
  // Enable CSP and allow inline script/style for this SPA.
57
  // Also allow connections to the upstream image API.
 
58
  app.use(helmet.contentSecurityPolicy({
59
  useDefaults: true,
60
  directives: {
@@ -65,10 +68,16 @@ app.use(helmet.contentSecurityPolicy({
65
  "font-src": ["'self'", "data:"],
66
  "connect-src": ["'self'", "https://image.chutes.ai"],
67
  "media-src": ["'self'", "data:", "blob:"],
68
- "frame-ancestors": ["'self'"]
69
  }
70
  }));
71
 
 
 
 
 
 
 
72
  app.use(cors());
73
  app.use(compression());
74
  app.use(express.json({ limit: '2mb' }));
 
50
 
51
  // Middlewares
52
  app.use(helmet({
53
+ crossOriginResourcePolicy: { policy: 'cross-origin' },
54
+ // Allow embedding on Hugging Face Spaces (disable X-Frame-Options)
55
+ frameguard: false
56
  }));
57
 
58
  // Enable CSP and allow inline script/style for this SPA.
59
  // Also allow connections to the upstream image API.
60
+ // Allow embedding inside Hugging Face Spaces iframe via frame-ancestors
61
  app.use(helmet.contentSecurityPolicy({
62
  useDefaults: true,
63
  directives: {
 
68
  "font-src": ["'self'", "data:"],
69
  "connect-src": ["'self'", "https://image.chutes.ai"],
70
  "media-src": ["'self'", "data:", "blob:"],
71
+ "frame-ancestors": ["'self'", "https://huggingface.co", "https://*.huggingface.co"]
72
  }
73
  }));
74
 
75
+ // Ensure no legacy X-Frame-Options header blocks embedding
76
+ app.use((req, res, next) => {
77
+ res.removeHeader('X-Frame-Options');
78
+ next();
79
+ });
80
+
81
  app.use(cors());
82
  app.use(compression());
83
  app.use(express.json({ limit: '2mb' }));