Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2e0fd39

Browse files
committed
FAQ.md: Document --proxy-path-passthrough
And the concerns surrounding it. Closes #2485
1 parent 61de421 commit 2e0fd39

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

‎doc/FAQ.md‎

Lines changed: 31 additions & 0 deletions
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)
@@ -201,6 +202,36 @@ code-server --proxy-domain <domain>
201202
Now you can browse to `<port>.<domain>`. Note that this uses the host header so
202203
ensure your reverse proxy forwards that information if you are using one.
203204

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+
204235
## Multi-tenancy
205236

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

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /