[object Object]

← back to AsSeenInMovies

asseeninmovies: trust proxy=1 + Cache-Control on sitemap.xml (3600s) and robots.txt (86400s). Cloudflare-friendly. Smoke 52/52.

cd952cb8488e14ec4e915570ccd34f09ce67083d · 2026-05-12 21:19:03 -0700 · SteveStudio2

Files touched

Diff

commit cd952cb8488e14ec4e915570ccd34f09ce67083d
Author: SteveStudio2 <stevestudio2@SteveStacStudio.lan>
Date:   Tue May 12 21:19:03 2026 -0700

    asseeninmovies: trust proxy=1 + Cache-Control on sitemap.xml (3600s) and robots.txt (86400s). Cloudflare-friendly. Smoke 52/52.
---
 server.js | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/server.js b/server.js
index 50127be..6602520 100644
--- a/server.js
+++ b/server.js
@@ -38,6 +38,10 @@ function isAdmin(req) {
 }
 
 const app = express();
+// Trust the first proxy hop (Cloudflare → Kamatera nginx → here). Lets
+// req.ip + req.protocol return the real client values from X-Forwarded-*
+// headers, which downstream rate-limit/logging needs.
+app.set('trust proxy', 1);
 // gzip compression for all responses ≥ 1KB. Big leverage on JSON-LD-heavy
 // HTML pages — /movies and /spotted carry full ItemList payloads now.
 app.use(compression({ threshold: 1024 }));
@@ -1753,6 +1757,7 @@ app.get('/sitemap.xml', async (_req, res) => {
     }
     const xml = `<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n  ${urls.join('\n  ')}\n</urlset>`;
     _sitemapCache = { at: now, xml };
+    res.setHeader('Cache-Control', 'public, max-age=3600');
     res.type('application/xml').send(xml);
   } catch (e) {
     res.status(500).type('text/plain').send(`error: ${e.message}`);
@@ -1874,6 +1879,7 @@ app.get('/favicon.ico', (_req, res) => {
 
 app.get('/robots.txt', (_req, res) => {
   const base = process.env.ASIM_PUBLIC_URL || 'https://asseeninmovies.com';
+  res.setHeader('Cache-Control', 'public, max-age=86400');
   res.type('text/plain').send(`User-agent: *\nAllow: /\nDisallow: /spotted/queue\nDisallow: /api/\nSitemap: ${base}/sitemap.xml\n`);
 });
 

← 5aadd3a asseeninmovies: gzip compression middleware (threshold 1KB)  ·  back to AsSeenInMovies  ·  asseeninmovies: GA4 gtag wiring (env-gated via GA_ID) on bot 9f98777 →