Skip to content

Subdomain Routing

The worker uses a SUBDOMAIN_ORIGINS map to route requests based on the Host header.

function extractSubdomain(hostname) {
const match = hostname.match(/^(.+)\.cubecommons\.org$/);
if (!match || match[1] === 'www') return null;
return match[1];
}

Multi-level subdomains are supported: sustainability-transparency.cubecommons.org extracts as sustainability.transparency.

Requests to bare cubecommons.org redirect to either:

  • home.cubecommons.org if the user has a valid cc_access cookie
  • token.cubecommons.org if not authenticated

Cookies are set with Domain=.cubecommons.org so they work across all subdomains. The cc_access cookie carries the token, and cc_sid carries the TOTP session.