Skip to content

Two hostname literals remain outside lib/seo.ts — one is a one-liner, one is an edge-runtime design question #199

Description

@hotlong

Raised by the #178 dev after that card collapsed robots.ts's own BASE into SITE_URL, taking hostname literals in apps/docs from four to three. Two are left, and they are not the same job.

What is left

1. apps/docs/app/layout.tsxmetadataBase. Declares new URL('https://docs.objectos.ai') as the base every relative metadata URL resolves against. Very likely the same one-line import that robots.ts took, but nobody has tried it — confirm rather than assume, since layout.tsx sits above the locale segment and was restructured by #168 (8feb90d).

2. apps/docs/middleware.ts — the canonical-domain redirect. This one is a design question, not a move. Middleware runs in the edge runtime, and importing lib/seo.ts there would drag the fumadocs source loader in with it. So it needs either a constant that lives somewhere both the edge runtime and the loader can reach, or a deliberate decision that middleware keeps its own copy.

That second option is defensible: middleware's literal answers "which host is canonical" for a redirect that runs before any page code, and coupling it to the module graph that builds pages has a cost of its own. But it should be a decision on the record, not a leftover.

Why it is worth a card rather than a note

lib/seo.ts:4 already carries the comment "Canonical production host. Keep in sync with middleware's domain redirect." — a hand-maintained sync obligation, written down and unenforced. That is the same shape as #173's STATIC_PAGE_LOCALES: correct today, silently wrong the day someone changes one side. The docs site has a canonical host in three places and a comment asking a human to remember.

Cheap and low-stakes — nothing is broken today, and both literals hold the same value. It is worth doing while the direction is fresh, and worth doing as one card so the middleware question gets answered rather than deferred a second time.

Constraints

  • Do the layout.tsx half only if it really is the one-line import. If it turns out to need more, stop and report — that would make it a second design question and this card would need re-scoping.
  • For middleware.ts, either outcome is acceptable: a shared constant that both runtimes can import, or a documented decision that it keeps its own literal. What is not acceptable is leaving the existing comment as the only mechanism. If the decision is "keep the copy", say so in code where both sides can see it, and make the comment state the reason rather than issuing an instruction to a human.
  • Verify the middleware redirect still works after any change — www.objectos.app must still 308 to docs.objectos.ai. It is the kind of thing that fails silently in production and nowhere else.

Provenance

Reported by the #178 dev rather than filed, with the edge-runtime constraint already diagnosed:

middleware.ts runs in the edge runtime, where importing lib/seo would drag the fumadocs source loader in, so collapsing those is a design question rather than the one-line move robots.ts turned out to be.

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions