Letting users put their own domain in front of Sarkoa maps.

Project date Platform engineering · Map hosting

If a consultancy wants to send clients to maps.theirfirm.com instead of maps.sarkoa.com, the experience should be identical - just with their name in the address bar.

A Worker is the small program that answers every request for a Sarkoa map page. A deployment is one running copy of it.

The one thing I refused to do was spin up a separate deployment per customer. Maintaining N copies of the exact same app just guarantees you’ll forget to patch one of them at the worst possible time. Instead, the exact same maps Worker that serves maps.sarkoa.com now serves every custom domain too.

How a request finds the right map

A customer hostname points at Sarkoa with a CNAME record. Cloudflare holds a certificate for that hostname and passes the request to the shared maps Worker, which looks the hostname up to find the organization and the maps assigned to it.

One deployment. The hostname resolves to an organization and its assigned maps before any map code runs.

  1. One DNS record: DNS is the internet’s phone book, turning a name into a place to send requests. The customer adds a CNAME record, which says “this name is really that name”: maps.theirfirm.com is really custom-hostnames.sarkoa.com.
  2. Cloudflare handles TLS: TLS is the padlock in the address bar. To show it, somebody has to hold a certificate proving the site really is maps.theirfirm.com, and Cloudflare gets one for each customer hostname. We track registration status and certificate status separately, with a scheduled Worker keeping both synced with Cloudflare. Nothing serves until both are active (and if a sync fails, it throws so it actually shows up in the logs instead of silently stalling).
  3. Same Worker, quick lookup: the Worker reads the hostname the request came in on. Requests for Sarkoa’s own domains skip the lookup; everything else looks the hostname up to find the organization that owns it and the specific maps assigned to it.

No accidental map leaks

That explicit map list is doing real security work. A custom domain can only open the maps its owner explicitly attached to it. Even if some other map on Sarkoa is public, requesting its ID on maps.theirfirm.com gets rejected. Your domain should only ever show your maps - never someone else’s.

Trying it for real first

Before opening this up to Pro workspaces, I ran a full dry run on a disposable dev workspace with a real external hostname (Cloudflare issued the cert, the custom domain served the test map) and ran a health sweep across production Workers, DB grants, and mobile/desktop map renders (raw rollout checks).

All posts