Skip to content

fix(api): resolve trusted visitor IPs across dashboard rate limits - #788

Merged
unjica merged 3 commits into
developfrom
fix/client-ip-resolution
Oct 12, 2026
Merged

unjica merged 3 commits into
developfrom
fix/client-ip-resolution

Conversation

@unjica

@unjica unjica commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

Railway internal proxy addresses previously determined rate-limit buckets. Resolve edge-set X-Real-IP and accept CF-Connecting-IP only from Cloudflare networks. All limiter scopes share the resolver; ingest adds the API key public ID to isolate projects behind a NAT. Existing limits and affiliate feature flags remain unchanged.

Server-side dashboard requests now forward each visitor IP with the existing AFFILIATE_CLIENT_IP_FORWARD_SECRET. The shared API resolver validates the secret in constant time before accepting a single visitor IP, giving dashboard auth/API requests separate visitor buckets. Both dashboard fetch helpers and all direct API callers use the guarded fetch wrapper. Forwarding credentials are omitted in browsers and when unconfigured. Dashboard IP resolution never uses XFF; duplicated Cloudflare ranges have a parity test.

Opt-in diagnostics include the dashboard source while excluding secrets and authorization headers. Deployment, environment examples, and changelog describe the configuration.

Validation:

  • API default suite: 140 files passed, 20 skipped; 1,140 tests passed, 163 skipped.
  • API with isolated local Postgres: 159 files passed, 1 skipped; 1,295 tests passed, 8 optional AI-service tests skipped. Includes affiliate integration and secret-forward tests.
  • Dashboard: 57 files and 307 tests passed.
  • API/dashboard ESLint with zero warnings: passed.
  • API and dashboard production builds: passed.
  • Full tsc --noEmit: existing 106 API and 6 dashboard errors in unchanged test files; no new errors. Production build type-checks pass.
  • Full base/working diff review and git diff --check: passed.

Postgres validation used a fresh isolated database initialized with Prisma db push, UTC, and the original migration seed rows because local Postgres 14 does not support the existing security_invoker migration. An initial run against an older local test schema failed for missing columns; the fresh-schema run passed.

Update existing ready PR #788 on fix/client-ip-resolution to develop. No MCP feature changes, limit reductions, merge, deployment, release, production data access, or affiliate disabling.

Resolve Railway edge and verified Cloudflare visitor IPs without enabling
global proxy trust. Share client identity across limiter scopes, partition
ingest by API key public ID, and preserve authenticated affiliate forwarding.

Add opt-in IP diagnostics, deployment guidance, and spoofing, IPv6, NAT,
and application-level rate-limit coverage.
Extend the shared client-IP resolver to authenticate dashboard forwarding
for every rate-limit scope using the existing server-only secret. Route
server-side dashboard API fetches through a guarded helper and resolve
visitors only through Railway and verified Cloudflare peers.

Preserve affiliate forwarding, add dashboard diagnostics and regression
coverage, and document the shared runtime configuration.
@unjica unjica changed the title fix(api): resolve trusted client IPs for rate limits fix(api): resolve trusted visitor IPs across dashboard rate limits Oct 12, 2026
@unjica
unjica merged commit ebf28a6 into develop Oct 12, 2026
7 checks passed
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