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:
Asher
2020-11-05 12:58:37 -06:00
parent 9e09c1f92b
commit 7b2752a62c
8 changed files with 134 additions and 145 deletions

View File

@@ -3,6 +3,7 @@ import qs from "qs"
import { HttpCode, HttpError } from "../../common/http"
import { authenticated, redirect } from "../http"
import { proxy } from "../proxy"
import { Router as WsRouter } from "../wsRouter"
export const router = Router()
@@ -35,7 +36,9 @@ router.all("/(:port)(/*)?", (req, res) => {
})
})
router.ws("/(:port)(/*)?", (req) => {
export const wsRouter = WsRouter()
wsRouter.ws("/(:port)(/*)?", (req) => {
proxy.ws(req, req.ws, req.head, {
ignorePath: true,
target: getProxyTarget(req, true),