Skip to content

Commit ade3d1e

Browse files
committed
FAQ.md: Document --proxy-path-passthrough
And the concerns surrounding it. Closes coder#2485
1 parent 18a3412 commit ade3d1e

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

doc/FAQ.md

+30
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,36 @@ code-server --proxy-domain <domain>
201201
Now you can browse to `<port>.<domain>`. Note that this uses the host header so
202202
ensure your reverse proxy forwards that information if you are using one.
203203

204+
## Why does the code-server proxy strip `/proxy/<port>` from the request path?
205+
206+
HTTP servers should strive to use relative URLs to avoid needed to be coupled to the
207+
absolute path at which they are served. This means you must use trailing slashes on all
208+
paths with subpaths. See https://stackoverflow.com/a/5458025/4283659
209+
210+
This is really the "correct" way things work and why the striping of the base path is the
211+
default. If your application uses relative URLs and does not assume the absolute path at
212+
which it is being served, it will just work no matter what port you decide to serve it off
213+
or if you put it in behind code-server or any other proxy!
214+
215+
However many people prefer the cleaner aesthetic of no trailing slashes. This couples you
216+
to the base path as you cannot use relative redirects correctly anymore. See the above
217+
stackoverflow link.
218+
219+
For users who are ok with this tradeoff, pass `--proxy-path-passthrough` to code-server
220+
and the path will be passed as is.
221+
222+
This is particularly a problem with the `start` script in create-react-app. See
223+
[#2222](https://github.com/cdr/code-server/issues/2222). You will need to inform
224+
create-react-app of the path at which you are serving via `homepage` field in your
225+
`package.json`. e.g. you'd add the following for the default CRA port:
226+
227+
```json
228+
"homepage": "/proxy/3000",
229+
```
230+
231+
Then visit `https://my-code-server-address.io/proxy/3000` to see your app exposed through
232+
code-server!
233+
204234
## Multi-tenancy
205235

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

0 commit comments

Comments
 (0)