Skip to content

Fix cookie domain not using --proxy-domain - #8076

Open
RaphaelFakhri wants to merge 1 commit into
coder:mainfrom
RaphaelFakhri:fix-cookie-domain-proxy-pattern
Open

RaphaelFakhri wants to merge 1 commit into
coder:mainfrom
RaphaelFakhri:fix-cookie-domain-proxy-pattern

Conversation

@RaphaelFakhri

Copy link
Copy Markdown

Fixes #8075

getCookieDomain is meant to set the session cookie on the highest level proxy domain so that one login covers code-server and every proxied port. Since #6225, --proxy-domain values are stored as patterns like {{port}}.example.com, and getCookieDomain compares the host against those patterns literally. The comparison never matches, so the cookie always falls back to the request host. For example, logging in on 8080.example.com sets Domain=8080.example.com and you have to log in again on example.com and on other ports.

This change takes the part of each pattern after the label that contains {{port}} ({{port}}.example.com and code-{{port}}.example.com both become example.com). It skips patterns that contain {{host}} because they do not name a fixed domain. Hosts that do not match a proxy domain, localhost, and IP addresses behave as before.

Testing

  • Added getCookieDomain tests to test/unit/node/http.test.ts. Without the source change, 2 of them fail (Received: "8080.example.com", Received: "test.example.com"). With it, the file passes (73 tests).
  • ./ci/dev/test-unit.sh --forceExit: 354 passed, 1 failed. The failure is createApp › should unlink a socket before listening on the socket, which expects EACCES and fails when run as root. It fails the same way without this change.
  • prettier --check, eslint, and tsc --noEmit pass.

@RaphaelFakhri
RaphaelFakhri requested a review from a team as a code owner October 24, 2026 17:18

This branch has not been deployed

No deployments
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.

Login cookie is scoped to the port subdomain instead of the proxy domain

1 participant