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