Fix Express trust proxy for Hugging Face Spaces
Browse filesEnable trust proxy in production to properly handle X-Forwarded-For
headers from HF Spaces infrastructure and fix rate limiting.
- server/index.ts +5 -0
server/index.ts
CHANGED
@@ -35,6 +35,11 @@ config({ path: join(__dirname, '../.env') });
|
|
35 |
|
36 |
const app = express();
|
37 |
|
|
|
|
|
|
|
|
|
|
|
38 |
console.log("✅ Express app created");
|
39 |
|
40 |
// IMMEDIATE fallback route - ensures HF Spaces gets a response no matter what
|
|
|
35 |
|
36 |
const app = express();
|
37 |
|
38 |
+
// Trust proxy for Hugging Face Spaces infrastructure
|
39 |
+
if (process.env.NODE_ENV === 'production') {
|
40 |
+
app.set('trust proxy', true);
|
41 |
+
}
|
42 |
+
|
43 |
console.log("✅ Express app created");
|
44 |
|
45 |
// IMMEDIATE fallback route - ensures HF Spaces gets a response no matter what
|