News platform Yuphora, published by APPDOOK, has detailed how it serves localized content editions across 13 countries without asking users for explicit browser geolocation permissions. By moving the selection logic into Next.js middleware, the platform determines a reader's location before rendering any page while relying entirely on existing request data.
A Tiered Fallback Resolution Order
To select an edition without location prompts, Yuphora's proxy layer evaluates four contextual hints in sequence. If a user previously selected an edition manually, a stored cookie takes highest priority to accommodate VPN users or explicit preferences. If no cookie exists, the middleware checks host-provided network geo headers derived from the user's IP address. If geo headers are absent, it uses the device's IANA time zone as a fallback. Should all signals fail, the system defaults to the United States edition.
Validating Headers and Filtering Time Zones
The team encountered several edge cases while implementing this chain. Host network headers do not always contain valid ISO country codes; services such as Cloudflare use non-standard identifiers like XX for unknown origins or numeric codes for Tor traffic. The middleware strips these out by validating country codes against a two-letter uppercase format.
Time zones also presented accuracy challenges. While zones such as Asia/Kolkata or Australia/Perth map cleanly to specific countries or cities, many time zones cross multiple national borders. Yuphora omitted ambiguous multi-country zones from its lookup table completely, preferring to fall back to the default edition rather than displaying an inaccurate regional guess.
Header Security and Cache Preservation
To prevent clients from forging location attributes, the Next.js middleware deletes any incoming local request headers before writing its own verified values, such as x-user-country, for downstream page routes. Additionally, city and region attributes are passed only when the requested edition matches the reader's detected country.
To maintain high performance on CDN and proxy caching layers like Nginx or Cloudflare, Yuphora avoids setting location cookies on static article pages. Because setting HTTP cookies prevents edge caches from storing content for search traffic, the middleware skips early for paths under /news/, delaying cookie creation until a reader visits an edition-dependent page.
AI-generated editorial illustration; not a documentary photograph.
Source: Local news without a location prompt: how we pick a reader's edition in Next.js

Leave a Reply