fix(webClientServer): use relative path in updateUrl #17
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.
Description
This patches the
webClientServer
to ensure theupdateUrl
is relative to the root.This ensures the correct URL in case code-server is being served behind a
reverse proxy.
An example of this would be using Caddy to server code-server on
localhost:8082/code/
This fix ensures request urls are created against localhost:8082/code/ instead
of localhost:8082/
Screenshot
Notice the Request URL in the image. Serving code-server regularly (i.e. on 8080), the update/check is made against the root.

When serving code-server behind a reverse-proxy with Caddy, the update/check is made against the reverse-proxy root (i.e.
/code/
Testing Plan
I tested against the root and the reverse-proxy.
cd vscode && git checkout jsjoeio-fix-csp-reverse-proxy
yarn link
cd code-server && yarn link code-oss-dev --modules-folder vendor/modules
Caddyfile
somewhere:caddy run
http://localhost:8082/code/
in the browser and check Network tab. Filter for "check" and look at the Headers tab for the request.I also did some basic testing around
new URL
in Codesandbox here.This PR fixes coder/code-server#4476
(There is a chance this fixes other reverse proxy issues, but I will test after this is merged).