Remove custom domain from tenants collection#972
Open
busbyk wants to merge 6 commits intorevert-926-revert-1.7.0from
Open
Remove custom domain from tenants collection#972busbyk wants to merge 6 commits intorevert-926-revert-1.7.0from
busbyk wants to merge 6 commits intorevert-926-revert-1.7.0from
Conversation
|
Preview deployment: https://revert-926-revert-1x7x0-remove--4993346.preview.avy-fx.org |
91bc6dd to
5f7a35e
Compare
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…urce of truth Eliminates the dual-source mismatch between the hardcoded AVALANCHE_CENTERS constant and the database tenants collection for custom domains. All custom domain lookups now use AVALANCHE_CENTERS, with a new getEmailDomain() utility for email domain matching that normalizes www. prefixes and ports. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace TenantIds with TenantSlugs in e2e test assertions since the payload-tenant cookie now stores slugs instead of numeric IDs. Remove the deprecated TenantIds constant. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
c191d39 to
5cda597
Compare
Collaborator
Author
Fixed! |
rchlfryn
requested changes
Mar 8, 2026
Collaborator
rchlfryn
left a comment
There was a problem hiding this comment.
Overall looks good - couple of comments
busbyk
commented
Mar 9, 2026
Comment on lines
+28
to
+33
| it('handles domains shared by multiple centers (returns first match)', () => { | ||
| // Multiple centers use 'alaskasnow.org': aaic, cac, earac, hac, vac | ||
| // Should return the first one found (aaic) | ||
| const result = findCenterByDomain('alaskasnow.org') | ||
| expect(result).toBe('aaic') | ||
| }) |
Collaborator
Author
There was a problem hiding this comment.
So I just realized how problematic this is. I don't think we should hold up this PR or #947 based on this because this is the same behavior we had before and we only need to solve for this when we onboard any of the alaskasnow.org centers. But I'll start a thread in Slack to discuss.
Collaborator
There was a problem hiding this comment.
I think this is fine to side step for now.
rchlfryn
approved these changes
Mar 9, 2026
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
Removes the
customDomainfield from thetenantscollection in the database, consolidating custom domain configuration into the hardcodedAVALANCHE_CENTERSconstant insrc/utilities/tenancy/avalancheCenters.ts. This eliminates a dual-source-of-truth problem where custom domains existed in both the database and the hardcoded constant, which could lead to mismatches.Related Issues
Follow-up to #947.
Key Changes
customDomainfield from the Tenants collection schema (src/collections/Tenants/index.ts) and generated typesgetEmailDomain()utility toavalancheCenters.ts— derives an email-safe domain from the custom domain by strippingwww.prefix and port numbersisTenantDomainScoped()— now usesfindCenterByDomain()fromAVALANCHE_CENTERSinstead of querying the database for custom domains, with a subdomain fallbackvalidateDomainAccessBeforeLoginandbyGlobalRoleOrTenantRoleAssignmentOrDomainnow use the newgetEmailDomain()utilitycustomDomainreferences from seed data20260303_233752_remove_custom_domain_from_tenants.tsdrops thecustom_domaincolumn from thetenantstablepayload-tenantcookie now stores slugs)How to test
pnpm seed:standalone— verify it completes without errorspnpm devand visitnwac.localhost:3000— verify the site resolves correctly via subdomainlocalhost:3000/admin— verify the admin panel loads and tenant selector workspnpm tscandpnpm lint— verify no type or lint errorspnpm test— verify all tests passScreenshots / Demo video
N/A — no visual changes
Migration Explanation
Migration:
20260303_233752_remove_custom_domain_from_tenantscustom_domaincolumn from thetenantstable (ALTER TABLE tenants DROP COLUMN custom_domain)ALTER TABLE tenants ADD custom_domain text)AVALANCHE_CENTERSconstant.