Spaces:
Running
Running
debug: add /debug-proxy endpoint + empty-200 warning log
Browse filesTemporary diagnostic: /debug-proxy?path=/foo probes nginx:5000 directly
and returns raw status/headers/body as JSON β bypasses health-server proxy
layer so we can see what nginx actually returns vs what we forward.
Also add console.warn for any 200 response from upstream that has no
content-type and no x-powered-by (the empty-body symptom we're chasing).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- health-server.js +32 -0
health-server.js
CHANGED
|
@@ -772,6 +772,38 @@ const server = http.createServer((req, res) => {
|
|
| 772 |
return;
|
| 773 |
}
|
| 774 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 775 |
// ββ /uptimerobot/setup βββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 776 |
if (pathname === "/uptimerobot/setup") {
|
| 777 |
if (req.method !== "POST") {
|
|
|
|
| 772 |
return;
|
| 773 |
}
|
| 774 |
|
| 775 |
+
// ββ /debug-proxy β probe nginx:5000 directly βββββββββββββββββββββββββββββ
|
| 776 |
+
// Returns raw status, headers, and body from nginx for any given path.
|
| 777 |
+
// Usage: /debug-proxy?path=/ or /debug-proxy?path=/app/
|
| 778 |
+
if (pathname === "/debug-proxy") {
|
| 779 |
+
const targetPath = parsedUrl.searchParams.get("path") || "/";
|
| 780 |
+
void (async () => {
|
| 781 |
+
try {
|
| 782 |
+
const result = await new Promise((resolve, reject) => {
|
| 783 |
+
const preq = http.request(
|
| 784 |
+
{ hostname: POSTIZ_HOST, port: POSTIZ_PORT, method: "GET", path: targetPath,
|
| 785 |
+
headers: { host: `${POSTIZ_HOST}:${POSTIZ_PORT}`, accept: "*/*", "user-agent": "debug-proxy/1.0" } },
|
| 786 |
+
(pres) => {
|
| 787 |
+
let body = "";
|
| 788 |
+
pres.setEncoding("utf8");
|
| 789 |
+
pres.on("data", (c) => { body += c; if (body.length > 4096) body = body.slice(0, 4096) + "β¦"; });
|
| 790 |
+
pres.on("end", () => resolve({ status: pres.statusCode, headers: pres.headers, body, bodyLen: body.length }));
|
| 791 |
+
},
|
| 792 |
+
);
|
| 793 |
+
preq.on("error", reject);
|
| 794 |
+
preq.setTimeout(5000, () => preq.destroy(new Error("timeout")));
|
| 795 |
+
preq.end();
|
| 796 |
+
});
|
| 797 |
+
res.writeHead(200, { "Content-Type": "application/json" });
|
| 798 |
+
res.end(JSON.stringify(result, null, 2));
|
| 799 |
+
} catch (e) {
|
| 800 |
+
res.writeHead(502, { "Content-Type": "application/json" });
|
| 801 |
+
res.end(JSON.stringify({ error: String(e) }));
|
| 802 |
+
}
|
| 803 |
+
})();
|
| 804 |
+
return;
|
| 805 |
+
}
|
| 806 |
+
|
| 807 |
// ββ /uptimerobot/setup βββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 808 |
if (pathname === "/uptimerobot/setup") {
|
| 809 |
if (req.method !== "POST") {
|