Repository navigation
feat(domains): auto-assign per-project subdomains when PANEL_BASE_DOMAIN is set - #46
Open
flavioduque wants to merge 1 commit into
Open
flavioduque wants to merge 1 commit into
flavioduque wants to merge 1 commit into
Conversation
…AIN is set With a wildcard DNS record (*.base) pointing at the proxy, every new instance gets api-<slug>.<base> (API) and <slug>.<base> (Studio, served through Kong's authenticated route) at creation time: domains are saved with their DNS check result, API_EXTERNAL_URL/SUPABASE_PUBLIC_URL are pointed at the HTTPS API domain, and the Traefik routing (file provider or Dokploy labels) is generated through the existing helpers. Without PANEL_BASE_DOMAIN nothing changes. Slugs that are not valid hostname labels are skipped and stay on manual domains. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Every new Supabase instance needs its API and Studio domains typed in by hand, plus one CNAME per domain at the DNS provider, before it is reachable over HTTPS. Operators who already own a wildcard record (
*.supa.example.com→ server) still have to repeat this for every instance.Fix
New optional env var
PANEL_BASE_DOMAIN. When it is set,createProjectassigns at creation time:api-<slug>.<PANEL_BASE_DOMAIN><slug>.<PANEL_BASE_DOMAIN>(served through Kong's authenticated dashboard route, like manual Studio domains)Then it does the same things as the manual
PUT /api/projects/[id]/domain:API_EXTERNAL_URL/SUPABASE_PUBLIC_URLat the HTTPS API domain;generateProjectTraefikConfig(file provider standalone, Kong labels on Dokploy).Routing is written last, so a failure earlier in the step goes through the existing creation rollback.
autoProjectDomains()lives next tovalidDnsTarget()insrc/lib/dns-target.ts. Hosts that are not valid DNS names (for example a slug that starts with-) are skipped, and that instance stays on manual domains.PANEL_BASE_DOMAINis passed through indocker-compose.yml(Dokploy) and theinstall.shcompose. The README documents the wildcard record.PANEL_BASE_DOMAIN, nothing changes.Verification
tests/auto-subdomain.test.ts: it was written first and failed 3/3 (autoProjectDomains is not a function); after the change it passes 3/3. It covers: base set → both hosts, lower-cased and trimmed; base unset/empty →null(old behaviour); invalid slug →null. A mutation check (removing the hostname validation) makes the third test fail.npm test: 14 pass, 0 fail, 3 skipped (opt-in integration tests).npm run lintis clean.npx tsc --noEmitpasses.Not verified
createProjectwiring (DB update, env update, Traefik generation) is checked only by reading the code and by type-checking. It was not executed, because it needs Postgres and a cloned Supabase template.provisionProjectFiles) do not get automatic subdomains; that is out of scope here.🤖 Generated with Claude Code