mirror of
https://github.com/coder/code-server.git
synced 2026-05-05 03:55:18 +02:00
Move websocket routes into a separate app
This is mostly so we don't have to do any wacky patching but it also makes it so we don't have to keep checking if the request is a web socket request every time we add middleware.
This commit is contained in:
@@ -2,6 +2,7 @@ import { Request, Router } from "express"
|
||||
import proxyServer from "http-proxy"
|
||||
import { HttpCode, HttpError } from "../common/http"
|
||||
import { authenticated, ensureAuthenticated } from "./http"
|
||||
import { Router as WsRouter } from "./wsRouter"
|
||||
|
||||
export const proxy = proxyServer.createProxyServer({})
|
||||
proxy.on("error", (error, _, res) => {
|
||||
@@ -82,7 +83,9 @@ router.all("*", (req, res, next) => {
|
||||
})
|
||||
})
|
||||
|
||||
router.ws("*", (req, _, next) => {
|
||||
export const wsRouter = WsRouter()
|
||||
|
||||
wsRouter.ws("*", (req, _, next) => {
|
||||
const port = maybeProxy(req)
|
||||
if (!port) {
|
||||
return next()
|
||||
|
||||
Reference in New Issue
Block a user