Skip to content

rsc-kit: set RSC_TRUST_FORWARDED=1, so requestClientIp() is the visitor's - #125

Merged
ramonmalcolm10 merged 1 commit into
mainfrom
rsc-trust-forwarded
Dec 6, 2026
Merged

ramonmalcolm10 merged 1 commit into
mainfrom
rsc-trust-forwarded

Conversation

@ramonmalcolm10

Copy link
Copy Markdown
Contributor

Without RSC_TRUST_FORWARDED, rsc-kit believes no forwarded header, so requestClientIp() returns the host proxy's address for every visitor. That breaks rate limits and anything else keyed on the visitor.

homeport's proxy writes the visitor's address as the whole X-Forwarded-For (one address, overwriting a visitor's own; docs/detection.md), so trusting one hop is right. rsc-kit counts hops from the right, so the value is 1. The pair supervisor adds no hop, so a renderer beside a backend gets the same value.

It's a managed value (MakeValue, runtime), like Laravel's LOG_CHANNEL=stderr: the control plane adds it at each build where the app has none of its own, so existing rsc-kit apps get it on their next deploy, and it's shown under Set by homeport for a new app. The bundle's .homeport/env couldn't carry it, because an rsc-kit server ships as a binary.

Reaches the control plane when its go.mod pin moves to the release with this.

Tests first: buildplan/managed_test.go (which apps get it, how it's made, its value). go test ./... and go vet pass. docs/detection.md's visitor-IP section has an rsc-kit line.

…or's

Unset, rsc-kit trusts no forwarded header and requestClientIp() is the
host proxy's address for every visitor. homeport's proxy writes the
visitor's address as the whole X-Forwarded-For (overwriting a visitor's
own), so one hop is right: a managed value, added at the next build
where the app has none of its own, as LOG_CHANNEL is for Laravel.
@ramonmalcolm10
ramonmalcolm10 merged commit d050652 into main Dec 6, 2026
5 checks passed
@ramonmalcolm10
ramonmalcolm10 deleted the rsc-trust-forwarded branch December 6, 2026 01:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant