Skip to content

feat: support dedicated API and MCP subdomains#200

Merged
ManukMinasyan merged 7 commits intomainfrom
feat/subdomain-routing
Mar 31, 2026
Merged

feat: support dedicated API and MCP subdomains#200
ManukMinasyan merged 7 commits intomainfrom
feat/subdomain-routing

Conversation

@ManukMinasyan
Copy link
Copy Markdown
Contributor

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.

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.
Copilot AI review requested due to automatic review settings March 29, 2026 20:24
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 /api prefix) and add a JSON info response at the domain root.
  • Update MCP route registration to serve MCP at / on the dedicated MCP domain (or /mcp on 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.
@ManukMinasyan ManukMinasyan merged commit 1ff2b29 into main Mar 31, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants