Custom Subdomains Match Exactly One Label, on Purpose
Claim a slug and your mock also answers at <slug>.mockbase.org instead of only mockbase.org/mock/<id>. The routing behind that is a single Host-header check, and it's stricter than it might look — deliberately.
The check
MockBase reads the incoming Host header, strips any port, lowercases it, and checks that it ends with .<base_host>. Whatever's left after removing that suffix has to be a single label — one segment, no dots — for the match to count. demo.mockbase.org resolves; demo.staging.mockbase.org does not, even though it technically "ends with" the base host too. If subdomain routing is disabled entirely (no base host configured), the check short-circuits and nothing matches.
Only when a request's Host header cleanly decomposes into exactly <label>.<base_host> does MockBase look up which mock owns that label and route the request to it.
Why "exactly one label" is the actual security property
The naive version of this feature — "does the Host header contain our domain?" — is a substring check, and substring checks on hostnames are a classic way to accidentally let something like mockbase.org.attacker.com or an unexpected multi-level subdomain slip through logic that wasn't built to handle it. Requiring the leftover portion to be a single, dot-free label rules that class of mismatch out structurally: there's no substring matching involved at all, just "does the host end with this exact suffix, and is there exactly one label in front of it."
It also means slug claims can't collide in confusing ways. A slug is a single label, claimed by exactly one mock at a time — there's no ambiguity about whether foo.bar.mockbase.org belongs to the owner of foo or bar, because that host simply never matches the routing rule in the first place.
What it costs you
No nested subdomains, no wildcard slugs, no multi-level namespacing under your own slug. For a feature whose entire job is "give this one mock a memorable, stable address," that's the right trade — the routing stays a single unambiguous string comparison instead of a general-purpose hostname parser, which is exactly the kind of code you want to be boring.
Xerat02
Building MockBase.
More from the blog
Your Mock's Access Token Is Shown to You Exactly Once
Turn on token protection and MockBase generates a token, shows it to you, and then — by design — never shows it to you again. Not in the UI, not through the API. If you didn't copy it, your only move is to rotate: generate a new one and invalidate the old.
Why Chaos Injection Uses a CSPRNG (and Rolls Fresh Every Request)
Real APIs fail sometimes — a flaky upstream, a timeout, a 500 under load. If your client code has never seen that happen, you don't actually know how it behaves when it does. Chaos injection makes MockBase fail on purpose, at a rate you choose, so you can find out before production does.