Code-server: Make Asset Paths Relative

Created on 14 Apr 2019  路  5Comments  路  Source: cdr/code-server

Deploying code-server to a nested URL such as /code will result in assets being requested from /, when they should be /code.

The HTML source code references root-level assets:

<script type="text/javascript" src="main.js"></script>

We should, instead, allow users to specify if they are hosting on a nested URL like /code, thus appending the host to the HTML:

./code-server --host=0.0.0.0/code
<script type="text/javascript" src="/code/main.js"></script>

Reproduction Steps

  1. Deploy to a URL like /code, or /johhny/codes
  2. Start code server
  3. Visit the URL, and observe that assets are not requested from the desired URL (code), but instead, are requested from the root / URL
bug

Most helpful comment

I just wanted to report that this does work, however if not logged in I get redirected away from my /code/ to /login/ which doesn't exist (should be /code/login/)

All 5 comments

Came here to report the same thing when reverse proxying with NGINX to /code

Paths are relative now.

Awesome. How do we specify the URL?

It's relative, so you don't need to specify anything. If code server is available at /code, resource requests will go to /code/resource, for example.

I just wanted to report that this does work, however if not logged in I get redirected away from my /code/ to /login/ which doesn't exist (should be /code/login/)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

infogulch picture infogulch  路  3Comments

nol166 picture nol166  路  3Comments

sa7mon picture sa7mon  路  3Comments

tecosaur picture tecosaur  路  3Comments

oonqt picture oonqt  路  3Comments