refactor(domain): inject domains via env vars, never hardcode or fall back #192

Merged
David merged 3 commits from feat/pms-235-mokosh-domain-rebrand into main 2026-06-13 14:31:46 +02:00
Owner

Summary

Supersedes the earlier mokosh.systems rebrand. The application runs on a different brand domain per environment (staging on a8n.systems, production on psa.systems), so no single domain may be baked into code or used as a fallback. Every domain is injected at runtime via environment variables.

This PR does two things: (1) removes the last hardcoded brand-domain literals from code, and (2) corrects all docs/comments/examples to the real staging/prod split and the canonical api.msp.<tld> API scheme.

Canonical names

Concern Staging Production
SaaS shell (apex) a8n.systems psa.systems
Mokosh app (SPA) msp.a8n.systems msp.psa.systems
Mokosh API api.msp.a8n.systems api.msp.psa.systems

The API host is api.msp.<tld> (prepend api. to the SPA host), matching the e2e derivation and the router's api.msp. strip. The outdated msp-api.<tld> form is gone.

Code changes (zero hardcoded brand domains remain)

  • src/api/router.rs: not_a_frontend no longer falls back to the literal https://a8n.systems. It now takes the env-injected client_origin (CLIENT_ORIGIN) as the fallback when the Host header cannot be parsed; the host-derived link (strip api.msp.) stays primary.
  • e2e/lib/env.ts: E2E_BASE_URL is now required (added to the preflight REQUIRED list) instead of defaulting to a hardcoded domain. CI already injects it from Forgejo secrets.
  • e2e/scripts/health-check.mjs, e2e/scripts/wait-for-deploy.mjs: fail loud when E2E_BASE_URL is unset instead of defaulting to a domain literal.

Docs / comments / examples corrected

  • src/main.rs, src/modules/auth/oidc_rs.rs: CORS_ORIGIN / OIDC_ISSUER / OIDC_AUDIENCE doc-comment and error-message examples now use the staging names.
  • dev-docs/milestone-1-handoff.md: target-topology table, OAuth redirect URIs, Cloudflare DNS, and verification curls restored to the staging/prod split and api.msp.<tld> scheme.
  • e2e/.env.example, e2e/README.md, e2e/playwright.config.ts, e2e/tests/global.setup.ts: harness host comments and the required E2E_BASE_URL example.

Verification

just check (cargo check + clippy + fmt --check) passes green. git grep mokosh.systems and git grep msp-api. return nothing; no a8n.systems/psa.systems string literal remains in any .rs file.

Note

The branch name (feat/pms-235-mokosh-domain-rebrand) still says "rebrand"; the work is no longer a rebrand. Left as-is to avoid recreating the PR, but the title/body now reflect the actual change.

## Summary Supersedes the earlier `mokosh.systems` rebrand. The application runs on a different brand domain per environment (staging on `a8n.systems`, production on `psa.systems`), so **no single domain may be baked into code or used as a fallback**. Every domain is injected at runtime via environment variables. This PR does two things: (1) removes the last hardcoded brand-domain literals from code, and (2) corrects all docs/comments/examples to the real staging/prod split and the canonical `api.msp.<tld>` API scheme. ## Canonical names | Concern | Staging | Production | | --- | --- | --- | | SaaS shell (apex) | `a8n.systems` | `psa.systems` | | Mokosh app (SPA) | `msp.a8n.systems` | `msp.psa.systems` | | Mokosh API | `api.msp.a8n.systems` | `api.msp.psa.systems` | The API host is `api.msp.<tld>` (prepend `api.` to the SPA host), matching the e2e derivation and the router's `api.msp.` strip. The outdated `msp-api.<tld>` form is gone. ## Code changes (zero hardcoded brand domains remain) - `src/api/router.rs`: `not_a_frontend` no longer falls back to the literal `https://a8n.systems`. It now takes the env-injected `client_origin` (`CLIENT_ORIGIN`) as the fallback when the `Host` header cannot be parsed; the host-derived link (strip `api.msp.`) stays primary. - `e2e/lib/env.ts`: `E2E_BASE_URL` is now **required** (added to the preflight `REQUIRED` list) instead of defaulting to a hardcoded domain. CI already injects it from Forgejo secrets. - `e2e/scripts/health-check.mjs`, `e2e/scripts/wait-for-deploy.mjs`: fail loud when `E2E_BASE_URL` is unset instead of defaulting to a domain literal. ## Docs / comments / examples corrected - `src/main.rs`, `src/modules/auth/oidc_rs.rs`: `CORS_ORIGIN` / `OIDC_ISSUER` / `OIDC_AUDIENCE` doc-comment and error-message examples now use the staging names. - `dev-docs/milestone-1-handoff.md`: target-topology table, OAuth redirect URIs, Cloudflare DNS, and verification curls restored to the staging/prod split and `api.msp.<tld>` scheme. - `e2e/.env.example`, `e2e/README.md`, `e2e/playwright.config.ts`, `e2e/tests/global.setup.ts`: harness host comments and the required `E2E_BASE_URL` example. ## Verification `just check` (cargo check + clippy + fmt --check) passes green. `git grep mokosh.systems` and `git grep msp-api.` return nothing; no `a8n.systems`/`psa.systems` string literal remains in any `.rs` file. ## Note The branch name (`feat/pms-235-mokosh-domain-rebrand`) still says "rebrand"; the work is no longer a rebrand. Left as-is to avoid recreating the PR, but the title/body now reflect the actual change.
docs(domain): rebrand a8n.systems references to mokosh.systems (Bucket A)
Some checks failed
E2E (staging) / Playwright against staging (pull_request) Failing after 15s
Check / fmt + clippy + compile + tests (pull_request) Successful in 1m24s
Build OCI container / Build and push mokosh-api image (push) Successful in 4m7s
ebaa8d2e36
Consolidate the Mokosh domain references onto the dedicated mokosh.systems brand (SPA mokosh.systems, API api.mokosh.systems) as agreed in PMS-235. This covers only Bucket A (docs, comments, test defaults; zero runtime risk): doc-comment examples in src/main.rs and src/modules/auth/oidc_rs.rs, the e2e harness defaults plus its README/.env.example/comments, and dev-docs/milestone-1-handoff.md (which also resolves the prior psa.systems-vs-mokosh.systems prod drift so the two no longer diverge).

The e2e harness keeps deriving the API host by prepending api. to the SPA host, so the new default https://mokosh.systems yields https://api.mokosh.systems with no logic change.

Bucket B live, infra-coupled values are deliberately left untouched: the client_origin fallback in src/api/router.rs:341, the real COOKIE_DOMAIN/issuer/audience values, and the shared-cookie SSO strategy with Bunyip. Those require matching DNS/cert/OIDC-client infra changes and are out of scope for this brand cleanup.

#PMS-235
refactor(domain): inject all domains via env; drop hardcoded fallbacks
Some checks failed
E2E (staging) / Playwright against staging (pull_request) Failing after 19s
Check / fmt + clippy + compile + tests (pull_request) Successful in 1m41s
Build OCI container / Build and push mokosh-api image (push) Successful in 3m37s
6cd85ca9b1
Supersedes the mokosh.systems rebrand. The app uses different brand domains per environment (staging a8n.systems, prod psa.systems), so no single domain may be baked into code or used as a fallback. Every domain is injected via env var.

Code (no hardcoded brand domain anywhere):
- src/api/router.rs: not_a_frontend no longer falls back to the literal https://a8n.systems. The handler now takes the env-injected client_origin (CLIENT_ORIGIN) as its fallback when the Host header can't be parsed; the host-derived link (strip api.msp.) stays primary.
- e2e/lib/env.ts: E2E_BASE_URL is now required (added to the preflight REQUIRED list) instead of defaulting to a hardcoded domain.
- e2e/scripts/health-check.mjs, e2e/scripts/wait-for-deploy.mjs: fail loud when E2E_BASE_URL is unset rather than defaulting to a domain literal.

Names (docs, comments, examples) corrected to the real staging/prod split and the canonical api.msp.<tld> API scheme (matches the code's derivation and the router's api.msp. strip), replacing the outdated msp-api.<tld> form:
- Staging: a8n.systems / msp.a8n.systems / api.msp.a8n.systems
- Prod: psa.systems / msp.psa.systems / api.msp.psa.systems
- src/main.rs, src/modules/auth/oidc_rs.rs: doc-comment / error-message examples.
- dev-docs/milestone-1-handoff.md: target topology table, OAuth redirects, DNS, verification curls.
- e2e/.env.example, e2e/README.md, e2e/playwright.config.ts, e2e/tests/global.setup.ts: harness host comments and the required E2E_BASE_URL example.

#PMS-235

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
David changed title from docs(domain): rebrand a8n.systems references to mokosh.systems (Bucket A) to refactor(domain): inject domains via env vars, never hardcode or fall back 2026-06-13 14:26:54 +02:00
Merge branch 'main' into feat/pms-235-mokosh-domain-rebrand
Some checks failed
Create release / Create release from merged PR (pull_request) Has been skipped
E2E (staging) / Playwright against staging (pull_request) Failing after 20s
Check / fmt + clippy + compile + tests (pull_request) Successful in 1m58s
Build OCI container / Build and push mokosh-api image (push) Successful in 4m13s
d155840aff
David merged commit 6f54b2bd38 into main 2026-06-13 14:31:46 +02:00
David deleted branch feat/pms-235-mokosh-domain-rebrand 2026-06-13 14:31:46 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/mokosh-server!192
No description provided.