fix(coder-routes): fix router collisions with web_extra_exposed_ports - #190
Merged
Merged
Conversation
Two bugs in the Traefik route generation broke any project using
web_extra_exposed_ports (e.g. an Astro/Vite dev server on a second port):
1. Slug derivation matched any router whose service was named
"{project}-web-{port}" (excluding 8025) as the primary site, with no
check on which port. A second web-based port (e.g. web-4321) computed
the same slug/router name as the real primary site (web-80), so
whichever was processed last silently clobbered the other's router in
the merged YAML map — breaking the main site's coder_app URL and
misrouting the extra port under the wrong Host-based rule. Restrict
the primary-site match to container port 80 specifically.
2. The dynamic add-on branch (for ports with no dedicated coder_app,
reached via Coder's dashboard port-forwarding URLs) used
PathPrefix(`/`) at priority 1. Every workspace's built-in catch-all
fallback router (ddev-router-fallback-http/-https) uses the identical
rule at the identical priority, and the tie resolves in the
fallback's favor — so these routers never actually received traffic,
silently swallowed by DDEV's generic "no route found" page. Bump to
priority 10 so it beats the fallback.
🤖 Developed with assistance from [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
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.
Summary
coder-routesderived the Coder slug for any Traefik router whose service was named{project}-web-{port}(except port 8025) as the primary site, with no check on which port. A project usingweb_extra_exposed_ports(e.g. an Astro/Vite dev server on a second port) gets a secondweb-named service ({project}-web-4321), which computed the same slug/router name as the real primary site ({project}-web-80). Whichever was processed last silently clobbered the other's router in the merged YAML map, breaking the main site'scoder_appURL and misrouting the extra port under the wrongHost()rule instead of the port-forwardingPathPrefixrule.coder_app, reached via Coder's dashboard port-forwarding URLs) setPathPrefix(/)atpriority: 1. Every workspace's built-in catch-all fallback router (ddev-router-fallback-http/-https, baked intodefault_config.yaml) uses the identical rule at the identical priority, and the tie resolves in the fallback's favor — so these routers never actually received traffic, silently swallowed by DDEV's generic "no route found" page.Fix
80specifically, so any otherweb-named port falls through to the dynamic add-on branch instead of colliding with the primary site.1to10so it beats the built-in fallback router.Reproduced and verified against a live workspace (ddev.com project with
web_extra_exposed_ports/web_extra_daemonsfor an Astro dev server on port 4321/4322): before the fix, both the main site's coder URL and the port-forward URL for 4322 returned 404; after the fix, both return 200, confirmed via directcurlagainst each Traefik entrypoint with the exactHostheaders Coder sends.Test plan
terraform fmt -recursive/terraform validate(no.tfchanges in this PR, script-only)web_extra_exposed_portsconfigured — main site, mailpit, and the extra-port dashboard-forward URL all route correctly after regenerating routes with the fixed script.github/workflows/integration-test.yml) exercisescoder-routesagainst a real workspace🤖 Generated with Claude Code
https://claude.ai/code/session_018ZFiSd6KTRmRNFzAhpL1eE