Skip to content

fix: preserve path and query in openExternal URL rewrite#7842

Open
1795771535y-cell wants to merge 1 commit into
coder:mainfrom
1795771535y-cell:fix/localhost-url-path-7668
Open

fix: preserve path and query in openExternal URL rewrite#7842
1795771535y-cell wants to merge 1 commit into
coder:mainfrom
1795771535y-cell:fix/localhost-url-path-7668

Conversation

@1795771535y-cell

Copy link
Copy Markdown

Description

Fixes #7668: The
esolveExternalUri function in the proxy-uri patch was discarding the original URI path and query parameters when rewriting localhost URLs to go through the code-server proxy.

Before

http://127.0.0.1:1234/my/path?q=1/proxy/1234/

After

http://127.0.0.1:1234/my/path?q=1/proxy/1234/my/path?q=1

Changes

  • Store the constructed proxy URL in a variable first
  • Append the original URI path (with leading / stripped) to the proxy URL pathname
  • Preserve the original URI query string by assigning it to the proxy URL search property

Testing

The fix preserves the path and query parameters from localhost URLs when they are rewritten through the code-server proxy endpoint template.

The resolveExternalUri function in the proxy-uri patch was discarding
the original URI path and query parameters when rewriting localhost URLs
to go through the code-server proxy.

Before: http://127.0.0.1:1234/my/path?q=1 -> /proxy/1234/
After:  http://127.0.0.1:1234/my/path?q=1 -> /proxy/1234/my/path?q=1

Fixes coder#7668
@1795771535y-cell 1795771535y-cell requested a review from a team as a code owner June 10, 2026 07:35
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.

localhost openExternal rewrite loses URL /path

1 participant