Skip to content

app/: routing by hostname (sc-8900) - #53

Merged
ndbroadbent merged 1 commit into
mainfrom
laravel-hosts
Dec 2, 2026
Merged

ndbroadbent merged 1 commit into
mainfrom
laravel-hosts

Conversation

@ndbroadbent

Copy link
Copy Markdown
Member

Ported from today's server/src/hosts.rs, as global middleware (stacked on #52).

  • With all four of VISUALCI_SITE_URL, VISUALCI_APP_URL, VISUALCI_API_URL and VISUALCI_MCP_URL set, each host serves only its own paths:
    • the app: the React app, sign-in and /api/ui;
    • the API: /api/v1, the webhooks and /status;
    • MCP: /mcp and the OAuth endpoints its clients call.
  • Anything else gets the same small 404 page as today. /up answers on every host.
  • The app's / sends a visitor without a session cookie (SESSION_COOKIE, default visualci_session) to the landing page.
  • Requests for any other host (a pod's own address, the cluster-internal address) get every path, as today.

Tests: today's unit test of which host serves which path, plus an integration test through the middleware with the hosts configured.

@visualci-com

visualci-com Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

VisualCI

docspring/visualci · build #207 · 331 unchanged · no changes

This PR vs base: 2 changed since #194, across 3 builds

Updated as builds change. Agents can review with VisualCI's MCP tools.

@ndbroadbent
ndbroadbent changed the base branch from laravel-sign-in to main December 2, 2026 13:14
…_URL set, the app, API and MCP hosts each serve only their own paths (a 404 page otherwise), the app's / sends a visitor without a session to the landing page, and any other host gets every path; ported from server/src/hosts.rs
@ndbroadbent
ndbroadbent merged commit f1c621c into main Dec 2, 2026
11 checks passed
@ndbroadbent
ndbroadbent deleted the laravel-hosts branch December 2, 2026 13:28
ndbroadbent added a commit that referenced this pull request Dec 2, 2026
…fuses to boot without all four host URLs; the host check judges a normalised path (percent-decoded, repeated slashes collapsed, lowercased), so /%61pi/v1, //api/v1 and /API/v1 can't reach the API through the app host; tests
ndbroadbent added a commit that referenced this pull request Dec 2, 2026
…fuses to boot without all four host URLs; the host check judges a normalised path (percent-decoded, repeated slashes collapsed, lowercased), so /%61pi/v1, //api/v1 and /API/v1 can't reach the API through the app host; tests
ndbroadbent added a commit that referenced this pull request Dec 2, 2026
…fuses to boot without all four host URLs; the host check judges a normalised path (percent-decoded, repeated slashes collapsed, lowercased), so /%61pi/v1, //api/v1 and /API/v1 can't reach the API through the app host; tests
ndbroadbent added a commit that referenced this pull request Dec 2, 2026
…fuses to boot without all four host URLs; the host check judges a normalised path (percent-decoded, repeated slashes collapsed, lowercased), so /%61pi/v1, //api/v1 and /API/v1 can't reach the API through the app host; tests
ndbroadbent added a commit that referenced this pull request Dec 2, 2026
* Routing by hostname, hardened (sc-8900, review of #53): production refuses to boot without all four host URLs; the host check judges a normalised path (percent-decoded, repeated slashes collapsed, lowercased), so /%61pi/v1, //api/v1 and /API/v1 can't reach the API through the app host; tests

* Routing by hostname, review fixes: production boots only when all four host URLs name a host and no two are the same (a bare app.visualci.com fails); in production a request for any other host reaches only /up and the renderers' /internal paths; Laravel's TrustHosts trusts every host, since it would refuse the API and MCP hosts and the pods' probes and route_by_host is the host check; tested in production for an unknown host and a boot that fails

* Routing by hostname: test that a forged Host gets no URL with its name in production (sign-in's callback, OAuth metadata, the device code and redirects are unreachable from it; every other URL comes from the configured host URLs)

* Routing by hostname: production boots with none of the four host URLs (one host serves everything, as a self-hosted VisualCI does, every URL from APP_URL) or all four, each naming a host and no two the same; only some of them is a boot error; tested in production for one host, the partial case, and four

* Routing by hostname on main: production-mode tests get storage and OAuth settings; one Cargo.toml tracing entry; the OAuth discovery test expects the tests' APP_URL (https://app.visualci.test, since #59)
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.

1 participant