Add request country header for incoming traffic
pavelpolyakov
HOBBYOP

2 months ago

Hi Railway team,

I’d like to request support for adding a country-of-origin header to incoming requests, based on the requester’s public IP.

A simple version would already be very useful, for example:

x-railway-ip-country: DE

using a standard ISO 3166-1 alpha-2 country code.

This would help with common use cases such as:

- country-based redirects or localization

- consent and compliance flows

- fraud/risk heuristics

- analytics enrichment

- pricing or feature gating by geography

- debugging traffic patterns without integrating a separate geo-IP service

There is precedent for this across other platforms:

Cloudflare provides the CF-IPCountry header, which contains a two-character country code for the originating visitor. Cloudflare’s IP geolocation feature adds this header to requests sent to the origin.

Documentation:

https://developers.cloudflare.com/fundamentals/reference/http-headers/

Vercel provides x-vercel-ip-country, also documented as a two-character ISO 3166-1 country code, along with related geo headers such as region and city.

Documentation:

https://vercel.com/docs/headers/request-headers

Because this pattern is already familiar to developers, Railway could expose something similar, for example:

- x-railway-ip-country

Optionally later:

- x-railway-ip-region

- x-railway-ip-city

- x-railway-ip-continent

A few implementation notes that would make this especially useful:

1. Use a stable ISO alpha-2 country code format.

2. Add the header before the request reaches the app/service.

3. Document behavior behind proxies and edge layers clearly.

4. Clarify whether the header is always present or omitted when country resolution is unavailable.

5. Make it trusted only when injected by Railway, so apps can rely on it safely.

This would remove the need for many apps to call third-party IP geolocation services themselves, reduce latency and complexity, and bring Railway closer to the ergonomics developers already expect from platforms like Cloudflare and Vercel.

Thanks for considering it.

Under Review

0 Threads mention this feature

0 Replies

Welcome!

Sign in to your Railway account to join the conversation.

Loading...