Spaces:
Sleeping
Sleeping
Enable trust proxy for Huggingface reverse proxy
Browse files
server.js
CHANGED
|
@@ -16,6 +16,10 @@ const app = express();
|
|
| 16 |
const PORT = process.env.PORT || 1234;
|
| 17 |
const HOST = '0.0.0.0'; // 监听所有网络接口
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
// Security middleware
|
| 20 |
app.use(helmet({
|
| 21 |
contentSecurityPolicy: {
|
|
|
|
| 16 |
const PORT = process.env.PORT || 1234;
|
| 17 |
const HOST = '0.0.0.0'; // 监听所有网络接口
|
| 18 |
|
| 19 |
+
// Trust proxy - 必须在使用 rate limiter 之前设置
|
| 20 |
+
// 这对于在反向代理(如 Huggingface Spaces)后面运行很重要
|
| 21 |
+
app.set('trust proxy', 1);
|
| 22 |
+
|
| 23 |
// Security middleware
|
| 24 |
app.use(helmet({
|
| 25 |
contentSecurityPolicy: {
|