Skip to content

Commit 56adea6

Browse files
roomote[bot]roomotemrubens
authored
docs: add subdomain routing to preview environments documentation (#529)
* docs: add subdomain routing to preview environments documentation * Apply suggestion from @roomote[bot] Co-authored-by: roomote[bot] <219738659+roomote[bot]@users.noreply.github.com> --------- Co-authored-by: Roo Code <roomote@roocode.com> Co-authored-by: Matt Rubens <mrubens@users.noreply.github.com> Co-authored-by: roomote[bot] <219738659+roomote[bot]@users.noreply.github.com>
1 parent 8dba6d5 commit 56adea6

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

‎docs/roo-code-cloud/environments.mdx‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ keywords:
1313
- Tool Versions
1414
- mise
1515
- Initial Path
16+
- Subdomain Routing
1617
---
1718

1819
# Preview Environments
@@ -91,6 +92,7 @@ ports:
9192
| `name` | Identifier for the port (used to generate environment variables) | Yes |
9293
| `port` | The port number to expose | Yes |
9394
| `initial_path` | Default path to append to the preview URL | No |
95+
| `subdomain` | Subdomain to set on the `Host` header when forwarding requests to the app | No |
9496

9597
For each named port, an environment variable is injected into your container:
9698

@@ -149,6 +151,44 @@ Query parameters and hash fragments are allowed. Valid examples:
149151
Invalid examples:
150152
- `login` (missing leading slash)
151153

154+
### Subdomain Routing
155+
156+
Use the `subdomain` field to enable subdomain-based routing for frameworks that rely on the `Host` header to distinguish tenants or admin panels (e.g., Rails, Django, Phoenix).
157+
158+
When a port has a `subdomain` configured, the proxy rewrites the `Host` and `X-Forwarded-Host` headers to `{subdomain}.localhost:{port}` before forwarding the request to your application. The browser URL stays unchanged -- the rewriting happens internally inside the sandbox.
159+
160+
```yaml
161+
ports:
162+
- name: WEB
163+
port: 3000
164+
subdomain: admin
165+
```
166+
167+
With this configuration, your application receives requests with `Host: admin.localhost:3000`, allowing it to route based on the subdomain without any DNS or infrastructure changes. WebSocket connections also receive the rewritten `Host` header.
168+
169+
#### Validation Rules
170+
171+
The `subdomain` value must be a valid DNS hostname:
172+
- Lowercase alphanumeric characters, hyphens, and dots only
173+
- Must start and end with an alphanumeric character
174+
- 1-253 characters long
175+
176+
Valid examples:
177+
- `admin`
178+
- `tenant1`
179+
- `us-west.api`
180+
181+
Invalid examples:
182+
- `Admin` (uppercase not allowed)
183+
- `-admin` (cannot start with a hyphen)
184+
- `admin-` (cannot end with a hyphen)
185+
186+
#### Use Cases
187+
188+
- **Multi-tenant apps**: Route `tenant1.localhost:3000` and `tenant2.localhost:3000` to different tenants in a single application
189+
- **Admin panels**: Serve an admin interface on `admin.localhost:3000` while the main app runs on the root domain
190+
- **Subdomain APIs**: Frameworks like Rails can use `api.localhost:3000` to route API requests to a separate controller namespace
191+
152192
## Using Environment Variables in Your Code
153193

154194
Use the `ROO_<NAME>_HOST` variables instead of hardcoded URLs so your services can find each other in both preview and local environments:

0 commit comments

Comments
 (0)