Skip to content

Commit 28c9e30

Browse files
committed
Update proxy path passthrough documentation
Includes updated create-react-app docs. Closes #2565
1 parent 8e4f3d8 commit 28c9e30

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

docs/FAQ.md

+15-12
Original file line numberDiff line numberDiff line change
@@ -226,25 +226,28 @@ However many people prefer the cleaner aesthetic of no trailing slashes. This co
226226
to the base path as you cannot use relative redirects correctly anymore. See the above
227227
link.
228228
229-
For users who are ok with this tradeoff, pass `--proxy-path-passthrough` to code-server
230-
and the path will be passed as is.
229+
For users who are ok with this tradeoff, use `/absproxy` instead and the path will be
230+
passed as is. e.g. `/absproxy/3000/my-app-path`
231231
232-
This is particularly a problem with the `start` script in create-react-app. See
232+
### Proxying to Create React App
233+
234+
You must use `/absproxy/<port>` instead with create-react-app.
235+
See [#2565](https://github.com/cdr/code-server/issues/2565) and
233236
[#2222](https://github.com/cdr/code-server/issues/2222). You will need to inform
234-
create-react-app of the path at which you are serving via `homepage` field in your
235-
`package.json`. e.g. you'd add the following for the default CRA port:
237+
create-react-app of the path at which you are serving via `$PUBLIC_URL` and webpack
238+
via `WDS_SOCKET_PATH`.
236239
237-
```json
238-
"homepage": "/proxy/3000",
240+
e.g.
241+
242+
```sh
243+
PUBLIC_URL=/absproxy/3000 \
244+
WDS_SOCKET_PATH=/absproxy/3000/sockjs-node \
245+
BROWSER=none yarn start
239246
```
240247

241-
Then visit `https://my-code-server-address.io/proxy/3000` to see your app exposed through
248+
Then visit `https://my-code-server-address.io/absproxy/3000` to see your app exposed through
242249
code-server!
243250

244-
Unfortunately `webpack-dev-server`'s websocket connections will not go through as it
245-
always uses `/sockjs-node`. So hot reloading will not work until the `create-react-app`
246-
team fix this bug.
247-
248251
Highly recommend using the subdomain approach instead to avoid this class of issue.
249252

250253
## Multi-tenancy

src/node/proxy.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ proxy.on("error", (error, _, res) => {
99
})
1010

1111
// Intercept the response to rewrite absolute redirects against the base path.
12-
// Is disabled when the request has no base path which means --proxy-path-passthrough has
13-
// been enabled.
12+
// Is disabled when the request has no base path which means /absproxy is in use.
1413
proxy.on("proxyRes", (res, req) => {
1514
if (res.headers.location && res.headers.location.startsWith("/") && (req as any).base) {
1615
res.headers.location = (req as any).base + res.headers.location

0 commit comments

Comments
 (0)