Fix -ui-dev serving 502 for every page - #6
Merged
Conversation
The dev-mode reverse proxy was built with NewSingleHostReverseProxy, which sets Director, and then had Rewrite assigned on top of it. ReverseProxy accepts exactly one of the two: with both set, ServeHTTP hands the request straight to the error handler and returns http: proxy error: ReverseProxy must have exactly one of Director or Rewrite set so every non-/api request under -ui-dev answered 502 instead of reaching the vite dev server. Running the UI against a live backend that way has never worked. Building the proxy from Rewrite alone keeps the intended behaviour -- Rewrite is the newer API and is what the SetURL/Host lines were written against -- and drops the Director that was only ever an artifact of the constructor. Nothing outside dev mode is affected: the branch is reached only when -ui-dev is passed, which is why the whole test suite and CI stayed green either way. libs/services had no tests at all, so the regression test comes with its own file. The test stands in for vite by binding localhost:4199, the hardcoded target, and skips rather than fails when that port is already taken. It drives a real server rather than a ResponseRecorder because ReverseProxy takes a different path when the request context has no Done channel -- which is part of why this survived so long unnoticed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AXB8suZYfpYZsSaoEps67m
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 dev-mode reverse proxy was built with NewSingleHostReverseProxy, which sets Director, and then had Rewrite assigned on top of it. ReverseProxy accepts exactly one of the two: with both set, ServeHTTP hands the request straight to the error handler and returns
http: proxy error: ReverseProxy must have exactly one of Director or
Rewrite set
so every non-/api request under -ui-dev answered 502 instead of reaching the vite dev server. Running the UI against a live backend that way has never worked.
Building the proxy from Rewrite alone keeps the intended behaviour -- Rewrite is the newer API and is what the SetURL/Host lines were written against -- and drops the Director that was only ever an artifact of the constructor.
Nothing outside dev mode is affected: the branch is reached only when -ui-dev is passed, which is why the whole test suite and CI stayed green either way. libs/services had no tests at all, so the regression test comes with its own file.
The test stands in for vite by binding localhost:4199, the hardcoded target, and skips rather than fails when that port is already taken. It drives a real server rather than a ResponseRecorder because ReverseProxy takes a different path when the request context has no Done channel -- which is part of why this survived so long unnoticed.
Claude-Session: https://claude.ai/code/session_01AXB8suZYfpYZsSaoEps67m