From f5c62388d611ce2c1670b97ac9f85efdca06fe65 Mon Sep 17 00:00:00 2001 From: Ben Stokes Date: Wed, 12 Aug 2026 15:07:13 -0700 Subject: [PATCH] fix: ip hops in cloud run environment --- apps/api/src/main.ts | 6 ++++-- apps/cli/package.json | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/api/src/main.ts b/apps/api/src/main.ts index 28844f3..1f42a4c 100644 --- a/apps/api/src/main.ts +++ b/apps/api/src/main.ts @@ -50,8 +50,10 @@ const port = parseInt(process.env.API_PORT || process.env.PORT || '3333', 10); const app = express(); -// Trust proxy for rate limiting behind reverse proxy -app.set('trust proxy', 1); +// Cloud Run sits behind Google Front End (and often an HTTPS LB), which +// appends an extra X-Forwarded-For hop. Trusting only 1 hop makes req.ip +// the shared load-balancer address. Self-hosted nginx is a single hop. +app.set('trust proxy', process.env.K_SERVICE ? 2 : 1); // Request logging (skip health checks) app.use(RequestLoggerWithSkip(['/api/health'])); diff --git a/apps/cli/package.json b/apps/cli/package.json index eb13e5b..228ac54 100644 --- a/apps/cli/package.json +++ b/apps/cli/package.json @@ -1,6 +1,6 @@ { "name": "@zoneless/cli", - "version": "0.1.9", + "version": "0.2.0", "description": "Provision and manage an agent-operated Zoneless store", "license": "Apache-2.0", "repository": {