Skip to content

fix(compat-plane): name the configured public address in /api/instances/, not the host the request came in on - #233

Merged
aRustyDev merged 1 commit into
mainfrom
fix/instances-public-origin
Nov 16, 2026
Merged

aRustyDev merged 1 commit into
mainfrom
fix/instances-public-origin

Conversation

@aRustyDev

Copy link
Copy Markdown
Owner

The first slice of #195's stage E: the code half of Q-0111.2.

The problem

/api/instances/ builds its three base URLs (admin_base_url, space_base_url, app_base_url) from the request's
Host. Behind the edge (ADR-0111), a target is a Worker Preview asked under its own workers.dev host, so the app would
be pointed at the Preview instead of the shared hostname. The spike found this (research/0016).

The change

A deployment that configures its public address now answers with that address, whatever the request's Host and
x-forwarded-proto say. The address is THRUST_PUBLIC_BASE_URL, which is already CoreConfig::public_base_url, the
base of the links in emails. A trailing / is dropped. With no address, or an empty one, the answer is the request's
origin, as before.

No current deployment changes: staging's public address is its own host. instance.rs is the only code that builds a
URL from Host (a search of crates/).

Tests (crates/api/compat-plane/tests/instance.rs)

Test What it shows
prop_a_configured_public_address_wins_over_the_request Any configured address, with or without a trailing /, against any Host and any scheme header, including none
an_empty_public_address_counts_as_none "", "/" and "///" fall back to the request's origin
behind_the_edge_… The case ADR-0111 names: a request under a Preview's host answers https://thrust.sow.foo

The existing properties for the Host-derived origin are unchanged.

Controls:

  • With the configured-address branch removed, exactly the two configured-address tests fail. The shrunk counterexample
    (a configured http://a, no Host) is committed as a regression seed.
  • cargo mutants on origin: 3 mutants, 3 caught.

Also passing: the whole crate (962 tests), clippy --all-targets -D warnings, fmt, and every deps step (14).

QUESTIONS.md

Q-0111.2 is narrowed, not closed. Left for the first release target:

  • the app, the OIDC callback, CSRF and the __Host- cookies behind the edge;
  • a target's configuration must set THRUST_PUBLIC_BASE_URL to the shared hostname, not its Preview's.

Refs #195

🤖 Generated with Claude Code

…es/, not the host the request came in on

/api/instances/ built its three base URLs (admin, space, app) from the request's Host. Behind the edge (ADR-0111), a
target is a Worker Preview asked under its own workers.dev host, so the app would be sent to the Preview instead of the
shared hostname (Q-0111.2, found by the spike, research/0016).

A deployment that configures its public address (THRUST_PUBLIC_BASE_URL, already CoreConfig::public_base_url, the base
of the links in emails) now answers with that address, without a trailing '/', whatever Host and x-forwarded-proto say.
With none, or an empty one, it is the request's origin as before. No deployment changes today: staging's public address
is its own host. It is the only route that builds a URL from Host (a search of crates/).

Tests (crates/api/compat-plane/tests/instance.rs):
- prop_a_configured_public_address_wins_over_the_request: any configured address, with or without a trailing '/',
  against any Host and any scheme header, including none;
- an empty, '/' or '///' address counts as none;
- the case ADR-0111 names: a request under a Preview's host answers with https://thrust.sow.foo.
The existing properties for the Host-derived origin are unchanged.

Controls:
- with the configured-address branch removed, exactly the two new configured-address tests fail;
- cargo mutants on `origin`: 3 mutants, 3 caught (including deleting the `!` of the empty check).
- the first control's shrunk counterexample (a configured http://a, no Host) is committed as a regression seed
  (tests/instance.proptest-regressions), so every run replays it.

Also run: the whole crate (962 passed), clippy --all-targets -D warnings, fmt, every deps step (14).

QUESTIONS.md: Q-0111.2 narrowed. Left for the first release target: the app, the OIDC callback, CSRF and the `__Host-`
cookies behind the edge, and a target's configuration setting THRUST_PUBLIC_BASE_URL to the shared hostname.

Refs: #195
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@aRustyDev
aRustyDev merged commit 3beb018 into main Nov 16, 2026
72 of 74 checks passed
@aRustyDev
aRustyDev deleted the fix/instances-public-origin branch November 16, 2026 22:13
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