Skip to content

Commit 58d72d5

Browse files
committed
routes/index.ts: register proxy routes before body-parser
Any json or urlencoded request bodies were being consumed by body-parser before they could be proxied. That's why requests without Content-Type were proxied correctly as body-parser would not consume their body. This allows the http-proxy package to passthrough the request body correctly in all instances. Closes #2377
1 parent f5cf3fd commit 58d72d5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/node/routes/index.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,6 @@ export const register = async (
6565
app.use(cookieParser())
6666
wsApp.use(cookieParser())
6767

68-
app.use(bodyParser.json())
69-
app.use(bodyParser.urlencoded({ extended: true }))
70-
7168
const common: express.RequestHandler = (req, _, next) => {
7269
// /healthz|/healthz/ needs to be excluded otherwise health checks will make
7370
// it look like code-server is always in use.
@@ -106,6 +103,12 @@ export const register = async (
106103
app.use("/", domainProxy.router)
107104
wsApp.use("/", domainProxy.wsRouter.router)
108105

106+
app.use("/proxy", proxy.router)
107+
wsApp.use("/proxy", proxy.wsRouter.router)
108+
109+
app.use(bodyParser.json())
110+
app.use(bodyParser.urlencoded({ extended: true }))
111+
109112
app.use("/", vscode.router)
110113
wsApp.use("/", vscode.wsRouter.router)
111114
app.use("/vscode", vscode.router)
@@ -121,9 +124,6 @@ export const register = async (
121124
})
122125
}
123126

124-
app.use("/proxy", proxy.router)
125-
wsApp.use("/proxy", proxy.wsRouter.router)
126-
127127
app.use("/static", _static.router)
128128
app.use("/update", update.router)
129129

0 commit comments

Comments
 (0)