← back to Agentabrams Viewer
chore: lint, refactor (dedup loadDomains, proxy-error writableEnded guard), version bump (session close)
4175e4a182319da284f6ac180310f3758ae414ac · 2026-07-22 19:20:43 -0700 · Steve Abrams
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Files touched
Diff
commit 4175e4a182319da284f6ac180310f3758ae414ac
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Wed Jul 22 19:20:43 2026 -0700
chore: lint, refactor (dedup loadDomains, proxy-error writableEnded guard), version bump (session close)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---
server.js | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/server.js b/server.js
index d3cb1e6..2334ca2 100644
--- a/server.js
+++ b/server.js
@@ -88,7 +88,8 @@ const server = http.createServer(async (req, res) => {
const slash = rest.indexOf('/');
const domain = slash < 0 ? rest : rest.slice(0, slash);
if (slash < 0) { res.writeHead(302, { Location: `/site/${domain}/` }); return res.end(); }
- if (!loadDomains().includes(domain)) { res.writeHead(404); return res.end('unknown domain'); }
+ const domains = loadDomains();
+ if (!domains.includes(domain)) { res.writeHead(404); return res.end('unknown domain'); }
const upstreamPath = rest.slice(slash) + url.search;
const headers = { ...req.headers, host: domain, authorization: UPSTREAM_AUTH };
delete headers.connection;
@@ -102,7 +103,7 @@ const server = http.createServer(async (req, res) => {
if (h.location) {
try {
const loc = new URL(h.location, `https://${domain}`);
- if (loadDomains().includes(loc.host)) h.location = `/site/${loc.host}${loc.pathname}${loc.search}`;
+ if (domains.includes(loc.host)) h.location = `/site/${loc.host}${loc.pathname}${loc.search}`;
} catch {}
}
if (h['set-cookie']) {
@@ -122,7 +123,7 @@ const server = http.createServer(async (req, res) => {
pres.pipe(res);
});
preq.on('timeout', () => preq.destroy(new Error('upstream timeout')));
- preq.on('error', (e) => { if (!res.headersSent) res.writeHead(502); res.end('proxy error: ' + e.message); });
+ preq.on('error', (e) => { if (res.writableEnded) return; if (!res.headersSent) res.writeHead(502); res.end('proxy error: ' + e.message); });
req.pipe(preq);
return;
}
← 8ef170b fix SSO cookie rewrite in site proxy: fleet-wide (Domain=) c
·
back to Agentabrams Viewer
·
5x sweep 1: handle aborted/failed api fetches in boot IIFE ( b807e6b →