Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/node/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,17 @@ export const register = async (app: App, args: DefaultedArgs): Promise<Disposabl
app.router.use("/", domainProxy.router)
app.wsRouter.use("/", domainProxy.wsRouter.router)

app.router.all("/proxy/(:port)(/*)?", (req, res) => {
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)
})
// These two routes pass through the path directly.
// So the proxied app must be aware it is running
// under /absproxy/<someport>/
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,
})
})
Expand Down
6 changes: 3 additions & 3 deletions src/node/routes/pathProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
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)
Expand Down