Overview
Every DeployHub project can be accessed via a subdomain or a custom domain. Subdomains are automatically generated during project creation and can be updated at any time.Domain Structure
Projects support two types of domains:Subdomain
Automatically generated:
{name}-{random}.deployhub.onlineCustom Domain
Your own domain:
www.example.comGet Project Domains
GET /api/projects/:id/domains
Retrieve domain configuration for a project.
string
required
Project ID (MongoDB ObjectId)
Subdomain Generation
Subdomains are automatically generated during project creation using this algorithm:Generation Logic
Subdomain Format
string
Format:
{project-name}-{6-char-random}- Project name is converted to lowercase
- Random string is 6 characters (base-36:
0-9,a-z) - Up to 20 attempts to ensure uniqueness
my-website-a3f5k2
Full URL
The complete domain is:{subdomain}.deployhub.online
Example: https://my-website-a3f5k2.deployhub.online
Update Subdomain
PATCH /api/projects/:id/domains/subdomain
Change the subdomain for a project. This triggers a container rebuild.
string
required
New subdomain (without
.deployhub.online)Validation: Must match pattern /^[a-z0-9-]{3,40}$/- Only lowercase letters, numbers, and hyphens
- Length: 3-40 characters
Subdomain Validation
my-siteproduction-app-2024web-app-v2my-project
My-Site(uppercase not allowed)my_site(underscores not allowed)ab(too short, minimum 3 characters)my.site(dots not allowed)
Uniqueness Check
The uniqueness check excludes the current project and deleted projects.
Subdomain Update Process
When updating a subdomain, several operations occur:1. Update Project Status
"building" during the subdomain transition.
2. Update Binding
Binding model tracks the port allocation for the subdomain.
3. Update Redis Cache
4. Queue Container Rebuild
Binding Model
TheBinding model manages domain-to-port mappings:
subdomain field is indexed for fast lookups
Port Allocation
For static projects:Custom Domains
Custom domains are tracked in the project model:Custom domain configuration endpoints are not shown in the provided source code. Custom domain setup may require additional DNS configuration and SSL certificate generation.
Redis Caching Strategy
Subdomains are cached in Redis for fast request routing: Key Format:subdomain:{subdomain-name}
Cached Data:
Example: Update Subdomain
Error Responses
400 Bad Request - Invalid Format
404 Not Found
409 Conflict
500 Server Error
Security Considerations
Ownership Verification
All domain operations verify that the authenticated user owns the project
Uniqueness Enforcement
Subdomain uniqueness is enforced at the database level with indexed queries
Status Filtering
Deleted projects are excluded from subdomain availability checks
Redis Sync
Redis cache is updated atomically with database changes