fix websocket upgrade for nuxt devtools

This commit is contained in:
Benjamin Flesch 2023-02-23 09:24:25 +00:00
parent b027af30d7
commit 00d2b90ea0

View File

@ -47,7 +47,14 @@ const proxyServer = http.createServer((req, res) => {
// upgrade client connection to websocket if requested // upgrade client connection to websocket if requested
proxyServer.on('upgrade', (req, socket, head) => { proxyServer.on('upgrade', (req, socket, head) => {
const isSocketIo = req.url.startsWith("/socket.io")
// choose backend depending on url
if (isSocketIo) {
proxySocketIO.ws(req, socket, head) proxySocketIO.ws(req, socket, head)
} else {
proxyNuxt.ws(req, socket, head)
}
}) })
proxyServer.listen(4000, () => console.log("proxy is listening")) proxyServer.listen(4000, () => console.log("proxy is listening"))