Skip to content

Keep classic-app school subdomains and dash/storefront out of new schools - #927

Merged
s3rot0n1n merged 10 commits into
platform-based-rewritefrom
feat/reserved-subdomains
Nov 26, 2026
Merged

s3rot0n1n merged 10 commits into
platform-based-rewritefrom
feat/reserved-subdomains

Conversation

@s3rot0n1n

@s3rot0n1n s3rot0n1n commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Why

The classic CourseLit app and the rewrite will share courselit.app. host-router sends a hostname to the classic app when a classic school owns it, and to the rewrite otherwise. So a new rewrite school must not take a classic school's subdomain. It also must not take dash or storefront, which Caddy serves as fixed hosts and which aren't in the base's reserved list yet.

What changes

  • Fixed list: dash and storefront are added to RESERVED_SUBDOMAINS in packages/api-contract/src/school-subdomain.ts.
  • Classic schools read as taken: apps/api/src/legacy-schools.ts asks the classic app GET <LEGACY_SCHOOL_CHECK_URL>?host=<label>.<domain> (codelitdev/courselit-subscriptions#60):
    • 200 means a classic school owns it.
    • 404 means it's free.
    • Anything else, or a 1.5 s timeout, throws (fail closed).
    • When the variable is unset (self-hosted installs), nothing is checked.
    • <domain> is LEGACY_SCHOOL_DOMAIN if set, otherwise PLATFORM_SITE_DOMAIN. Only QA needs it, because there the classic app serves schools on clqa.site while the rewrite uses courselit.cluster.clqa.site. Prod leaves it unset.
  • Where it's used:
    • The availability check (takenAmong): the name reads as taken, like the base's reserved names. For suggestions, only the first 4 still-free candidates are checked, in one parallel round, and only those can be offered; the wizard shows 3. Checking all 11 at once took up to 1.5 s on QA and timed out.
    • POST /v1/schools: 409 subdomain_taken. The check sits in the route, not in createSchool, so staff imports of classic schools still work.
  • Admin wizard: Continue is now disabled while the address is taken or invalid, not just while it's being checked. The field already explains why inline.
  • Unchanged: the contract and the database.

Deploying

  • Infra main sets LEGACY_SCHOOL_CHECK_URL for QA and prod, plus LEGACY_SCHOOL_DOMAIN=clqa.site on QA.
  • The classic subscriptions app must run v0.7.3 or later, which has /school/exists, before the rewrite uses this. Otherwise every name would read as free.
  • With the variable set, the classic app being down blocks new school creation, by design.
  • Verified on QA with a hand-built image (pr-927-c09e68a): a classic school's subdomain shows as taken, with suggestions.

Tests

  • New: legacy-schools.test.ts, 5 tests through the real routes with a local stand-in classic app: owned, suggestions, create refused, a free name created, the LEGACY_SCHOOL_DOMAIN override, classic app failing → 500, variable unset → not consulted.
  • Existing: onboarding.test.ts passes. The full API suite passed (808 tests) before the latest two commits. Admin onboarding tests: 30 pass. Contract tests: 65 pass.
  • Typecheck: passes for apps/api, apps/admin and packages/api-contract.

🤖 Generated with Claude Code

New schools can no longer take product or infrastructure hostnames
(RESERVED_SUBDOMAINS in code) or subdomains listed in the new
reserved_subdomains table, which operators fill from a local file with
migrate:reserved-subdomains so customer data stays out of the repository.

The availability check reports "reserved" and leaves reserved names out
of suggestions; createSchool rejects them with a subdomain_reserved
conflict; the setup wizard says the address isn't available.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-25T01:39:04.204469Z 37951e0 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 37951e026d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/api/drizzle/0000_baseline.sql Resolved
Rajat and others added 5 commits November 25, 2026 10:51
…s as taken

- Custom domains can't be the platform domain, a name under it (www,
  product hosts, school subdomains) or a .localhost name: 409
  hostname_reserved, shown in domain settings as "This domain isn't
  available."
- createSchool and createSchoolCustomHost map a unique violation on the
  subdomain or hostname constraints to subdomain_taken / hostname_taken
  instead of failing; the pre-checks stay
- Reserve mcp, webhook(s), internal, platform, prod, production, beta,
  localhost and courselit, matching FrontLit

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolve conflicts with the base's own reserved-subdomain work: the fixed
list now lives only in @courselit/api-contract (union of both lists), and
the API's reserved_subdomains table adds names reserved in the database.
Static names are refused by the contract schema; database-reserved names
get a 409 subdomain_reserved from createSchool. The availability check
reports both as "reserved".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The table was folded into 0000_baseline.sql but not into the snapshot, so
the next `db:generate` would emit a CREATE TABLE that fails on databases
built from the baseline. `db:generate` now reports no schema changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…table

Replace the reserved_subdomains table and its import script with a live
check against the classic app (LEGACY_SCHOOL_CHECK_URL, GET <url>?host=).
A subdomain or custom domain a classic school owns is refused; when the
classic app can't be asked the address is refused for now
(legacy_check_unavailable, or reason "unavailable" from the availability
check). Unset skips the check. The fixed product hostname list stays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keep only what the shared courselit.app needs: classic-app school
subdomains read as taken (availability check, suggestions and
POST /v1/schools, via LEGACY_SCHOOL_CHECK_URL, failing closed), and
`dash` and `storefront` join the fixed reserved list. Drop the
custom-host checks, platform-hostname check, unique-violation mapping,
new availability reason, admin copy and README changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@s3rot0n1n s3rot0n1n changed the title Reserve product and old-school subdomains in the rewrite Keep classic-app school subdomains and dash/storefront out of new schools Nov 25, 2026
Rajat and others added 4 commits November 25, 2026 23:32
…tch stub

The spyOn(globalThis, "fetch") stub leaked into later test files in the
same process, so their fetch calls returned undefined (29 CI failures).
Serve the classic app's answers from Bun.serve on a random port instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ic app

On QA the classic app serves schools on a different domain from the
rewrite, so asking about <label>.<PLATFORM_SITE_DOMAIN> never matched a
classic school. LEGACY_SCHOOL_DOMAIN overrides it; prod leaves it unset.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Eleven parallel calls took up to 1.5 s against the classic app on QA and
hit the timeout, failing the whole availability check. Ask about the
first four still-free candidates only; the wizard shows three.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…alid

The field already says why inline; the button no longer looks usable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@s3rot0n1n
s3rot0n1n merged commit aee1990 into platform-based-rewrite Nov 26, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant