Repository navigation
fix(compat-plane): name the configured public address in /api/instances/, not the host the request came in on - #233
Merged
Conversation
…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]>
Merged
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.
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'sHost. Behind the edge (ADR-0111), a target is a Worker Preview asked under its own workers.dev host, so the app wouldbe 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
Hostandx-forwarded-protosay. The address isTHRUST_PUBLIC_BASE_URL, which is alreadyCoreConfig::public_base_url, thebase of the links in emails. A trailing
/is dropped. With no address, or an empty one, the answer is the request'sorigin, as before.
No current deployment changes: staging's public address is its own host.
instance.rsis the only code that builds aURL from
Host(a search ofcrates/).Tests (
crates/api/compat-plane/tests/instance.rs)prop_a_configured_public_address_wins_over_the_request/, against anyHostand any scheme header, including nonean_empty_public_address_counts_as_none"","/"and"///"fall back to the request's originbehind_the_edge_…https://thrust.sow.fooThe existing properties for the
Host-derived origin are unchanged.Controls:
(a configured
http://a, noHost) is committed as a regression seed.cargo mutantsonorigin: 3 mutants, 3 caught.Also passing: the whole crate (962 tests),
clippy --all-targets -D warnings,fmt, and everydepsstep (14).QUESTIONS.md
Q-0111.2 is narrowed, not closed. Left for the first release target:
__Host-cookies behind the edge;THRUST_PUBLIC_BASE_URLto the shared hostname, not its Preview's.Refs #195
🤖 Generated with Claude Code