@@ -201,6 +201,36 @@ code-server --proxy-domain <domain>
201
201
Now you can browse to ` <port>.<domain> ` . Note that this uses the host header so
202
202
ensure your reverse proxy forwards that information if you are using one.
203
203
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
+
204
234
## Multi-tenancy
205
235
206
236
If you want to run multiple code-servers on shared infrastructure, we recommend using virtual
0 commit comments