Skip to content

Commit 497b01b

Browse files
committed
FAQ.md: Document --proxy-path-passthrough
And the concerns surrounding it. Closes #2485
1 parent f169e3a commit 497b01b

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

doc/FAQ.md

+31
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- [How do I securely access web services?](#how-do-i-securely-access-web-services)
1616
- [Sub-paths](#sub-paths)
1717
- [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)
1819
- [Multi-tenancy](#multi-tenancy)
1920
- [Docker in code-server container?](#docker-in-code-server-container)
2021
- [How can I disable telemetry?](#how-can-i-disable-telemetry)
@@ -208,6 +209,36 @@ code-server --proxy-domain <domain>
208209
Now you can browse to `<port>.<domain>`. Note that this uses the host header so
209210
ensure your reverse proxy forwards that information if you are using one.
210211
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+
211242
## Multi-tenancy
212243

213244
If you want to run multiple code-servers on shared infrastructure, we recommend using virtual

0 commit comments

Comments
 (0)