diff --git a/src/node/routes/index.ts b/src/node/routes/index.ts index 13d53df86..a2046b6a7 100644 --- a/src/node/routes/index.ts +++ b/src/node/routes/index.ts @@ -94,8 +94,8 @@ export const register = async (app: App, args: DefaultedArgs): Promise { - pathProxy.proxy(req, res) + app.router.all("/proxy/(:port)(/*)?", async (req, res) => { + await pathProxy.proxy(req, res) }) app.wsRouter.get("/proxy/(:port)(/*)?", async (req) => { await pathProxy.wsProxy(req as pluginapi.WebsocketRequest) @@ -103,8 +103,8 @@ export const register = async (app: App, args: DefaultedArgs): Promise/ - app.router.all("/absproxy/(:port)(/*)?", (req, res) => { - pathProxy.proxy(req, res, { + app.router.all("/absproxy/(:port)(/*)?", async (req, res) => { + await pathProxy.proxy(req, res, { passthroughPath: true, }) }) diff --git a/src/node/routes/pathProxy.ts b/src/node/routes/pathProxy.ts index 6c20ab6b3..e21b849ec 100644 --- a/src/node/routes/pathProxy.ts +++ b/src/node/routes/pathProxy.ts @@ -14,14 +14,14 @@ const getProxyTarget = (req: Request, passthroughPath?: boolean): string => { return `http://0.0.0.0:${req.params.port}/${req.params[0] || ""}${query ? `?${query}` : ""}` } -export function proxy( +export async function proxy( req: Request, res: Response, opts?: { passthroughPath?: boolean }, -): void { - if (!authenticated(req)) { +): Promise { + if (!(await authenticated(req))) { // If visiting the root (/:port only) redirect to the login page. if (!req.params[0] || req.params[0] === "/") { const to = self(req)