Blog · · 3 min read
One origin: site and API on one host
Splitting the marketing site from the API moves the session cookie cross-site, which browsers block. Running both on jobwzrd.com removes CORS and a whole class of auth bugs.
Most small products split into app.example.com and api.example.com, then spend a week on CORS, credentials and SameSite. JobWzrd does the opposite: one Worker serves the page, the app and /api/* on jobwzrd.com.
The cookie problem
A session cookie set on api.example.com and read by app.example.com is cross-site. Browsers refuse to attach it without SameSite=None, which then requires Secure, explicit CORS and an origin allow-list that has to be right on every deployment. Each of those is a way to be logged out for reasons nobody can reproduce.
On one hostname the cookie is first-party by construction. There is no CORS preflight, no token in local storage, and no Authorization header to leak — the request carries the cookie because it is the same site.
What it costs
- One deploy ships the site and the API together, so a rollback rolls both back.
- The static export has to travel inside the Worker, with its CSP and asset headers compiled into the bundle.
- Programmatic clients get their own hostname and per-user API keys, because a CLI holding a cookie is a worse idea than a scoped key.
The boring architecture is the one where “it logged me out” has one possible cause.
It also made the marketing site measurable: the same origin serves robots.txt, the sitemap and the pages it lists, so a canonical URL is a fact rather than an assumption about DNS.