Skip to content

Commit a619627

Browse files
authored
fix: ip hops in cloud run environment (#122)
1 parent 65ccc43 commit a619627

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

apps/api/src/main.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,10 @@ const port = parseInt(process.env.API_PORT || process.env.PORT || '3333', 10);
5050

5151
const app = express();
5252

53-
// Trust proxy for rate limiting behind reverse proxy
54-
app.set('trust proxy', 1);
53+
// Cloud Run sits behind Google Front End (and often an HTTPS LB), which
54+
// appends an extra X-Forwarded-For hop. Trusting only 1 hop makes req.ip
55+
// the shared load-balancer address. Self-hosted nginx is a single hop.
56+
app.set('trust proxy', process.env.K_SERVICE ? 2 : 1);
5557

5658
// Request logging (skip health checks)
5759
app.use(RequestLoggerWithSkip(['/api/health']));

apps/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@zoneless/cli",
3-
"version": "0.1.9",
3+
"version": "0.2.0",
44
"description": "Provision and manage an agent-operated Zoneless store",
55
"license": "Apache-2.0",
66
"repository": {

0 commit comments

Comments
 (0)