Skip to main content
GET
Project Domains

Get Project Domains

string
required
The unique identifier of the project (MongoDB ObjectId)

Authentication

Requires JWT authentication via the verifyJWT middleware.

Response

boolean
required
Indicates whether the request was successful
object
required
Domain configuration for the project

Example Request

Example Response

Example Response (With Custom Domain)


Update Subdomain

Update the DeployHub subdomain for a project. This triggers a container recreation with the new subdomain.

Path Parameters

string
required
The unique identifier of the project

Request Body

string
required
The new subdomain. Must be 3-40 characters long, containing only lowercase letters, numbers, and hyphens.

Validation Rules

  • Pattern: Must match regex /^[a-z0-9-]{3,40}$/
  • Length: 3-40 characters
  • Characters: Lowercase letters (a-z), numbers (0-9), hyphens (-) only
  • Uniqueness: Subdomain must not be taken by another active project
  • Invalid examples:
    • MY-APP (uppercase not allowed)
    • my_app (underscores not allowed)
    • ab (too short)
    • my app (spaces not allowed)

Behavior

  1. Validates subdomain format and uniqueness
  2. Updates the subdomain in the project document
  3. Sets project status to building
  4. Updates the port binding allocation
  5. Updates Redis cache with new subdomain mapping
  6. Queues a container recreation job
  7. Project will rebuild and restart with the new subdomain

Example Request

Example Response


Error Responses

Returned when the subdomain doesn’t meet validation requirements
Returned when:
  • Project with the specified ID doesn’t exist
  • Project doesn’t belong to the authenticated user
  • Project has been deleted
Returned when the subdomain is already taken by another project
Returned when a server error occurs during the update process

Implementation Notes

Subdomain Update Process

  1. Validation Phase:
    • Checks subdomain format using regex validation
    • Queries database to ensure subdomain is not already taken
    • Ignores the current project when checking uniqueness
    • Excludes deleted projects from uniqueness check
  2. Update Phase:
    • Updates project document with new subdomain
    • Sets status to building (bypasses validation)
    • Updates the Binding (port allocation) document
    • Removes old subdomain from Redis cache
    • Creates new Redis cache entry with port mapping
  3. Recreation Phase:
    • Queues a job to deployhub-recreate-container queue
    • Job data includes: projectId, oldcontainername, newcontainername
    • Container is recreated with the new subdomain
    • Project becomes accessible at {new-subdomain}.deployhub.online

Redis Cache Structure

The subdomain cache stores:
  • Key: subdomain:{subdomain}
  • Value (hash):
    • port: Internal port number for routing
    • projectId: Project identifier
    • plan: Subscription plan for rate limiting

Downtime

Updating a subdomain causes temporary downtime as the container is recreated. During this time:
  • Project status is building
  • The old subdomain becomes inaccessible
  • The new subdomain is not yet available
  • Typical recreation time: 1-3 minutes depending on project size

Custom Domains

This endpoint only handles DeployHub subdomains. Custom domain configuration (for pro plan users) is handled separately and requires DNS verification.

Source Reference

  • GET domains: backend/src/controllers/slices/Project/domain.controller.js:6
  • PATCH subdomain: backend/src/controllers/slices/Project/domain.controller.js:29