From ee6287e7062fbedaab3d24429c13ea8fa5112c63 Mon Sep 17 00:00:00 2001 From: giteaadmin Date: Sat, 23 Aug 2025 11:38:20 -0400 Subject: [PATCH] feat: enable trust proxy for correct handling of protocols and client IPs --- src/server.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/server.js b/src/server.js index 5085f88..2806884 100644 --- a/src/server.js +++ b/src/server.js @@ -6,6 +6,13 @@ const path = require('path'); const app = express(); const port = 3000; // You can change this port if needed +// Enable trust proxy to ensure Express correctly handles protocols (http/https) +// and client IP addresses when running behind a reverse proxy. +// This is crucial for correct URL generation in redirects and for security features +// like rate limiting. The value 'true' trusts the X-Forwarded-* headers +// set by the immediate upstream proxy. +app.set('trust proxy', true); + // Path to the file where view counts will be stored const dbPath = path.join(__dirname, '_data', 'views.json');