fix(dev): make the local tenant-site fallback self-explanatory - #8
Merged
Merged
Conversation
Public pages resolve the tenant from the host, and DEFAULT_COMPANY_SLUG is applied to signed-in areas only, so plain localhost always falls back to the platform marketing page. The existing log said "no-tenant-host-match" without saying what to do about it, and the natural reading — "my database is not seeded" — is usually wrong. Development now logs the cause, both supported local entry points, and the company slugs actually present in the database, so a genuinely unseeded database is distinguishable from correct host-based behavior. Once per host per process, never in production. The resolution rule itself is unchanged. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…t access The README stated that tenant public pages can use DEFAULT_COMPANY_SLUG in development. They cannot: the fallback is deliberately restricted to authenticated areas so it can never serve one tenant's public site on another host. Following the old text leads to "localhost shows the platform page" and a hunt for a database fault that does not exist. Adds "Opening A Tenant Site Locally" covering ?devTenant= and <slug>.localhost, which of the two is the day-to-day workflow, and the create/migrate/seed commands for a genuinely empty database. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Next skips .env.local when NODE_ENV=test, so running CI's own E2E command locally started a server with no DATABASE_URL and reported every migration missing — a false failure that is easy to misread as a broken local database. NODE_ENV=development keeps the dev-session bypass available on a production build and loads .env.local locally; CI supplies its database through the job env either way. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
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.
The report
npm run dev+ http://localhost:3000 renders the platform marketing page instead of a tenant site, logging:The natural reading is "my local database has no seeded company". That reading is wrong, and the README actively encouraged it.
What is actually happening
Verified against the local database before changing anything:
estateos_devatlocalhost:5432prisma migrate status: up to date, 51/51acme-realtycompany exists?devTenant=acme-realtyandacme-realty.localhost:3000both render it/api/readyzconfigured: true,migrations.missing: []The cause is in
resolveTenantContext:DEFAULT_COMPANY_SLUGis deliberately not consulted for public pages, so a fallback can never serve one tenant's public site on another host in production.localhosttherefore can never show a tenant site regardless of seeding — the log even shows the fallback slug being resolved and then discarded.No production rule is changed here. Only the explanation is.
Changes
Actionable dev log — on fallback, development now logs the cause, both supported entry points, and the company slugs actually present, so an unseeded database is distinguishable from correct host-based behavior:
Once per host per process, never in production. When no companies exist it says to run
npm run db:seed.README — corrected the false claim that public pages use
DEFAULT_COMPANY_SLUGin development (the line that caused this), and added "Opening A Tenant Site Locally" with both workflows and the create/migrate/seed commands.CI — the E2E server now runs as
NODE_ENV=developmentrather thantest. Next skips.env.localunderNODE_ENV=test, so running CI's own command locally started a server with no database and reported every migration missing. That false failure cost real debugging time in this session;developmentkeeps the dev-session bypass available on a production build and loads.env.locallocally, while CI supplies its database through the job env either way.Verification
npm run checknpm run migrations:check🤖 Generated with Claude Code