You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 56adea6
Browse filesBrowse the repository at this point in the historyBrowse files
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>
Copy file name to clipboardExpand all lines: docs/roo-code-cloud/environments.mdx
+40Lines changed: 40 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,7 @@ keywords:
13
13
- Tool Versions
14
14
- mise
15
15
- Initial Path
16
+
- Subdomain Routing
16
17
---
17
18
18
19
# Preview Environments
@@ -91,6 +92,7 @@ ports:
91
92
| `name` | Identifier for the port (used to generate environment variables) | Yes |
92
93
| `port` | The port number to expose | Yes |
93
94
| `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 |
94
96
95
97
For each named port, an environment variable is injected into your container:
96
98
@@ -149,6 +151,44 @@ Query parameters and hash fragments are allowed. Valid examples:
149
151
Invalid examples:
150
152
- `login`(missing leading slash)
151
153
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
+
152
192
## Using Environment Variables in Your Code
153
193
154
194
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