feat: support dedicated API and MCP subdomains#200
Merged
ManukMinasyan merged 7 commits intomainfrom Mar 31, 2026
Merged
Conversation
When API_DOMAIN is set, API routes are served on the subdomain without the /api prefix (e.g. api.relaticle.com/v1/*) and root returns JSON info. When MCP_DOMAIN is set, MCP endpoint moves to root path on the subdomain (e.g. mcp.relaticle.com/). Both fall back to path-based routing on the main domain when env vars are unset.
There was a problem hiding this comment.
Pull request overview
Adds support for serving the REST API and MCP endpoints on dedicated subdomains when configured, while preserving path-based routing when the domain env vars are unset.
Changes:
- Conditionally register API routes on a dedicated domain (no
/apiprefix) and add a JSON info response at the domain root. - Update MCP route registration to serve MCP at
/on the dedicated MCP domain (or/mcpon the main domain). - Adjust exception JSON rendering to treat requests to the API domain as JSON responses.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| routes/ai.php | Switch MCP endpoint between /mcp (path mode) and / on a configured MCP subdomain. |
| bootstrap/app.php | Conditionally disables default /api routing and mounts API routes on a configured API subdomain; adds API root JSON info and updates JSON exception rendering logic. |
- Consolidate API route registration into single then: callback - When API_DOMAIN set: routes at api.example.com/v1/* (no /api prefix) - When unset: routes at /api/v1/* (default behavior) - When MCP_DOMAIN set: MCP at mcp.example.com/ (no /mcp path) - SubdomainRootResponse middleware returns JSON info for subdomain roots - Add 6 routing tests covering both path and subdomain modes
- Make SubdomainRootResponse readonly to satisfy arch test - Use url() helper instead of config concatenation for docs URLs
…eaks Replace putenv + refreshApplication() with config() overrides and inline Route::domain() registration in each test. The previous approach leaked static state that caused Filament table tests to fail when run in the same shard.
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When API_DOMAIN is set, API routes are served on the subdomain without the /api prefix (e.g. api.relaticle.com/v1/*) and root returns JSON info. When MCP_DOMAIN is set, MCP endpoint moves to root path on the subdomain (e.g. mcp.relaticle.com/). Both fall back to path-based routing on the main domain when env vars are unset.