Draft
Conversation
|
Preview deployment: https://revert-926-revert-1x7x0.preview.avy-fx.org |
* Switch to dynamicParams=true so centers not pre-built at build time can be served on-demand * Replace invariant crashes with notFound() calls for graceful handling when DB data is missing. * Resolve merge conflicts with main * Revert test change * Revert missing platform or metadata to correctly 500 * Add generic notFound page at app level without tenant branding * return 404 if no tenant matches a subdomain * Rewrite unknown subdomains to render styled 404 instead of plain text * Add title to blank metadata object * using getURL for find your local avalanche center link to always navigate to root domain even on invalid subdomains or custom domains * removing [...segmentsNotFound] in favor of global level not-found file (frontend) route group is just for folder organization so (frontend)/not-found is at top level * adding same valid tenant checks and metadata fetch error handling to page.tsx since it's called in parallel with layout.tsx * matching dynamicParams settings in layout.tsx and page.tsx -- both set to true for proper 404 handling * refactoring the unrecognized subdomain logic slightly with a logCompletion string change for clarity + adding similar logic for matching custom domain for center not configured for production --------- Co-authored-by: Kellen Busby <kellenbusby@gmail.com>
Migration Safety CheckFound 2 potential issues: 20260303_233752_remove_custom_domain_from_tenants.ts Warning (line 5): DROP keyword detected - review for data loss await db.run(sql`ALTER TABLE \`tenants\` DROP COLUMN \`custom_domain\`;`)Warning (line 5): ALTER keyword detected - review for data loss await db.run(sql`ALTER TABLE \`tenants\` DROP COLUMN \`custom_domain\`;`)Review these patterns and add backup/restore logic if needed. See |
91bc6dd to
5f7a35e
Compare
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.
Description
Re-lands the tenant lookup refactor (#897) that was reverted in #926 due to false 404s in production. This PR includes the original refactor, the routing fix from #949, and the removal of
customDomainfrom the database (#972) — consolidating all tenant resolution into the hardcodedAVALANCHE_CENTERSconstant as a single source of truth.The original revert was caused by
dynamicParams = falserequiringgenerateStaticParams()to perfectly match what middleware sends — when it didn't, routes silently fell through to the catch-all 404. The fix usesdynamicParams = trueso middleware handles "is this slug valid?" and the layout handles "does this center have data?", each doing what it's best positioned to do.Related Issues
Reverts #926, re-lands #897, includes #972
Related: #579, #914
Key Changes
Tenant lookup refactor (from #897 / #949)
AVALANCHE_CENTERS— middleware is now synchronous and deterministicpayload-tenantcookie now stores slugs instead of numeric IDsdynamicParams = true— centers in the DB are pre-rendered at build time; others served on-demand with graceful 404 handlinginvariant→notFound()— proper 404 pages instead of 500 crashes when a center lacks DB datauseTenantLookuphook and refactorTenantSelectionProviderto use the new lookupdocs/decisions/013-hardcoded-tenant-lookup.mdand manual test cases indocs/tenant-selector.mdRemove
customDomainfrom database (from #972)customDomainfield from Tenants collection — all custom domain config now lives inAVALANCHE_CENTERSgetEmailDomain()utility — derives email-safe domain from custom domain by strippingwww.prefix and port numbersisTenantDomainScoped()— usesfindCenterByDomain()instead of querying the database20260303_233752_remove_custom_domain_from_tenantsdrops thecustom_domaincolumnHow to test
pnpm seed:standalone— verify it completes without errorspnpm devand visitnwac.localhost:3000— should render normallyAVALANCHE_CENTERSbut not in the DB — should show the not-found page, not crashlocalhost:3000/admin— verify the admin panel loads and tenant selector workspnpm tsc,pnpm lint, andpnpm test— verify no errorsScreenshots / Demo video
See demo from original PR: https://www.loom.com/share/4c083b90aedf4df983eab130db9b1783
Migration Explanation
Migration:
20260303_233752_remove_custom_domain_from_tenantscustom_domaincolumn from thetenantstableAVALANCHE_CENTERS)Future enhancements / Questions
/adminroutes on subdomains/custom domains to the root domain, since we already direct users use the root domain in production