|
15 | 15 | - [How do I securely access web services?](#how-do-i-securely-access-web-services)
|
16 | 16 | - [Sub-paths](#sub-paths)
|
17 | 17 | - [Sub-domains](#sub-domains)
|
| 18 | +- [Why does the code-server proxy strip `/proxy/<port>` from the request path?](#why-does-the-code-server-proxy-strip-proxyport-from-the-request-path) |
18 | 19 | - [Multi-tenancy](#multi-tenancy)
|
19 | 20 | - [Docker in code-server container?](#docker-in-code-server-container)
|
20 | 21 | - [How can I disable telemetry?](#how-can-i-disable-telemetry)
|
@@ -208,6 +209,36 @@ code-server --proxy-domain <domain>
|
208 | 209 | Now you can browse to `<port>.<domain>`. Note that this uses the host header so
|
209 | 210 | ensure your reverse proxy forwards that information if you are using one.
|
210 | 211 |
|
| 212 | +## Why does the code-server proxy strip `/proxy/<port>` from the request path? |
| 213 | +
|
| 214 | +HTTP servers should strive to use relative URLs to avoid needed to be coupled to the |
| 215 | +absolute path at which they are served. This means you must use trailing slashes on all |
| 216 | +paths with subpaths. See https://blog.cdivilly.com/2019/02/28/uri-trailing-slashes |
| 217 | +
|
| 218 | +This is really the "correct" way things work and why the striping of the base path is the |
| 219 | +default. If your application uses relative URLs and does not assume the absolute path at |
| 220 | +which it is being served, it will just work no matter what port you decide to serve it off |
| 221 | +or if you put it in behind code-server or any other proxy! |
| 222 | +
|
| 223 | +However many people prefer the cleaner aesthetic of no trailing slashes. This couples you |
| 224 | +to the base path as you cannot use relative redirects correctly anymore. See the above |
| 225 | +link. |
| 226 | +
|
| 227 | +For users who are ok with this tradeoff, pass `--proxy-path-passthrough` to code-server |
| 228 | +and the path will be passed as is. |
| 229 | +
|
| 230 | +This is particularly a problem with the `start` script in create-react-app. See |
| 231 | +[#2222](https://github.com/cdr/code-server/issues/2222). You will need to inform |
| 232 | +create-react-app of the path at which you are serving via `homepage` field in your |
| 233 | +`package.json`. e.g. you'd add the following for the default CRA port: |
| 234 | +
|
| 235 | +```json |
| 236 | + "homepage": "/proxy/3000", |
| 237 | +``` |
| 238 | + |
| 239 | +Then visit `https://my-code-server-address.io/proxy/3000` to see your app exposed through |
| 240 | +code-server! |
| 241 | + |
211 | 242 | ## Multi-tenancy
|
212 | 243 |
|
213 | 244 | If you want to run multiple code-servers on shared infrastructure, we recommend using virtual
|
|
0 commit comments