Skip to content

Conversation

@amirhmoradi
Copy link

What is this PR about?

Custom Wildcard Domains: Configure wildcard domains at the organization or project level for generated application and preview URLs.

NOTE: This takes over from #3297

Checklist

Before submitting this PR, please make sure that:

Issues related (if applicable)

None

Screenshots (if applicable)

TBD

claude and others added 7 commits December 9, 2025 15:07
Add the ability for organization admins and project admins to configure
custom wildcard domains that replace the default traefik.me subdomains
for auto-generated application domains.

Features:
- Organization-level wildcard domain setting (e.g., *-apps.example.com)
- Project-level wildcard domain override with inheritance option
- Updated domain generation to use custom wildcards when configured
- New UI components for configuring wildcard domains in settings
- Domain dialog tooltip shows active wildcard domain pattern

The domain generation follows this hierarchy:
1. Project-specific wildcard domain (if set)
2. Organization wildcard domain (if project inherits and org has one)
3. Default traefik.me domain (fallback)

Example: Setting wildcard domain to "*-apps.example.com" will generate
domains like "myapp-a1b2c3-apps.example.com" for new applications.
…-domain-implementation-and-test

Handle preview wildcard domains in generated hosts
…ustom-wildcard-domains-01Pa52auo5dyyAmSUGfCTvSr
The wildcard domain migration (originally 0131_dry_rictor.sql) conflicted
with the canary branch migration 0131_volatile_beast.sql. The journal only
tracked the canary migration, causing the wildcard migration to never be
applied.

Changes:
- Renamed 0131_dry_rictor.sql to 0134_add_wildcard_domains.sql to avoid
  index conflict with 0131_volatile_beast.sql
- Updated _journal.json to reference the new migration at idx 134
- Removed the invalid 0133_vibrant_melville entry (file did not exist)
- Fixed 0134_snapshot.json to properly chain from 0132 and include all
  required columns (createEnvFile, isDefault, wildcardDomain,
  useOrganizationWildcard)

This ensures drizzle-orm will correctly detect and apply the wildcard
domain migration when the code is deployed.
Move migration execution to run BEFORE app.prepare() to ensure database
schema changes are applied before any queries are made. This fixes errors
like "column wildcardDomain does not exist" on existing installations
when new schema columns are added.

The previous order was:
1. app.prepare() - Next.js loads and may query DB
2. migration() - too late, queries already failed

New order:
1. migration() - apply schema changes first
2. app.prepare() - safe to query with new columns
This fixes the "column wildcardDomain does not exist" error that occurs
when the wildcard domain migration hasn't been applied yet.

The issue was that auth queries used `organization: true` which selects
ALL columns from the organization table, including wildcardDomain.
When validateRequest runs before migration completes, this causes errors.

Changed to only select the specific columns actually needed:
- Session creation callback: only needs organization.id
- API key validation: only needs organization.ownerId
- Session validation: only needs organization.ownerId

This is the proper fix because:
- It doesn't modify migration or startup logic
- It only selects what's actually needed (better for performance too)
- Works regardless of migration timing
- Follows the principle of minimal data selection
@amirhmoradi amirhmoradi force-pushed the claude/fix-wildcard-migrations-IFoqx branch from a23046b to 20e5967 Compare December 22, 2025 20:45
Fixes the migration not being applied on existing installations:

1. Renamed migration from 0134 to 0133 to fill the gap in sequence
2. Added IF NOT EXISTS to handle partial migration failures gracefully
3. Updated journal and snapshot with fresh IDs

This ensures the migration is recognized as new and will be applied
even if a previous attempt failed partially.
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.

2 participants