From c0492ebf537082ba6525a075c6c2980280bb61ca Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Mon, 9 Nov 2026 18:05:18 -0500 Subject: [PATCH] Guard against missing x-forwarded-for on socket connect Co-Authored-By: Claude Opus 5.5 --- backend/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/index.js b/backend/index.js index 3366b02..36f63f2 100644 --- a/backend/index.js +++ b/backend/index.js @@ -261,7 +261,7 @@ function parseHeader(header) { io.sockets.on('connection', function (client) { const header_ipAddress = parseHeader(client.handshake.headers["forwarded"] || ""); const cf_ipAddress = client.handshake.headers["cf-connecting-ip"]; - const x_ipAddress = client.handshake.headers["x-forwarded-for"].split(",")[0]; + const x_ipAddress = client.handshake.headers["x-forwarded-for"]?.split(",")[0]; const ipAddress = cf_ipAddress || x_ipAddress || header_ipAddress; clients[client.id] = { socket: client, active: false }; clients[client.id].timestamp = new Date();