Server-Side Rendering on Country Subdomains: What We Got Wrong First
Server-Side Rendering on Country Subdomains: What We Got Wrong First 24ad.info is a classifieds site where every country has its own subdomain — pl.24ad.info , de.24ad.info , gb.24ad.info — all served by one app. The frontend is a React 19 single-page app built with Vite, running on Express behind Caddy, with everything behind Cloudflare. A single-page app has a well-known weakness: the first…
The wire story covers the challenges faced by 24ad.info, a classifieds site with country-specific subdomains. Initially, the site struggled with ensuring proper first HTML responses and correct metadata for each country subdomain.
In April, they adjusted canonical URLs to match the subdomain the request originated from, and implemented a geo-redirect to send visitors to their respective country's subdomain. However, this redirect became a permanent 301 instead of the temporary 302 initially used.
In May, they attempted to inject data into the first HTML response for improved performance. While this worked well for listing pages, it caused issues on the home page where listings were country-specific. The injected data did not apply to the home page, leading to a mix of UK and global listings for users on their own country's home page. They quickly removed this feature.
Currently, the site renders the home page, listing pages, and category pages with custom metadata and initial data injected by the server. All other routes use the standard app template. Static assets are served directly from Caddy with long-term caching. The site block covers both the main domain and subdomains using a wildcard certificate.
The key takeaways from the story are that canonical URLs should be specific to each subdomain, the geo-redirect should exclude search engine bots, logged-in users, and users who explicitly select the global view, and pre-rendered data must be scoped to match the live page's country.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.