mirror of https://github.com/coder/code-server.git
parent
eae285cf93
commit
f169e3ac66
|
@ -50,6 +50,7 @@ export interface Args extends VsArgs {
|
||||||
"show-versions"?: boolean
|
"show-versions"?: boolean
|
||||||
"uninstall-extension"?: string[]
|
"uninstall-extension"?: string[]
|
||||||
"proxy-domain"?: string[]
|
"proxy-domain"?: string[]
|
||||||
|
"proxy-path-passthrough"?: boolean
|
||||||
locale?: string
|
locale?: string
|
||||||
_: string[]
|
_: string[]
|
||||||
"reuse-window"?: boolean
|
"reuse-window"?: boolean
|
||||||
|
@ -172,6 +173,10 @@ const options: Options<Required<Args>> = {
|
||||||
"uninstall-extension": { type: "string[]", description: "Uninstall a VS Code extension by id." },
|
"uninstall-extension": { type: "string[]", description: "Uninstall a VS Code extension by id." },
|
||||||
"show-versions": { type: "boolean", description: "Show VS Code extension versions." },
|
"show-versions": { type: "boolean", description: "Show VS Code extension versions." },
|
||||||
"proxy-domain": { type: "string[]", description: "Domain used for proxying ports." },
|
"proxy-domain": { type: "string[]", description: "Domain used for proxying ports." },
|
||||||
|
"proxy-path-passthrough": {
|
||||||
|
type: "boolean",
|
||||||
|
description: "Whether the path proxy should leave the /proxy/<port> in the request path when proxying.",
|
||||||
|
},
|
||||||
"ignore-last-opened": {
|
"ignore-last-opened": {
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
short: "e",
|
short: "e",
|
||||||
|
|
|
@ -8,12 +8,12 @@ import { Router as WsRouter } from "../wsRouter"
|
||||||
|
|
||||||
export const router = Router()
|
export const router = Router()
|
||||||
|
|
||||||
const getProxyTarget = (req: Request, rewrite: boolean): string => {
|
const getProxyTarget = (req: Request, passthroughPath: boolean): string => {
|
||||||
if (rewrite) {
|
if (passthroughPath) {
|
||||||
const query = qs.stringify(req.query)
|
return `http://0.0.0.0:${req.params.port}/${req.originalUrl}`
|
||||||
return `http://0.0.0.0:${req.params.port}/${req.params[0] || ""}${query ? `?${query}` : ""}`
|
|
||||||
}
|
}
|
||||||
return `http://0.0.0.0:${req.params.port}/${req.originalUrl}`
|
const query = qs.stringify(req.query)
|
||||||
|
return `http://0.0.0.0:${req.params.port}/${req.params[0] || ""}${query ? `?${query}` : ""}`
|
||||||
}
|
}
|
||||||
|
|
||||||
router.all("/(:port)(/*)?", (req, res) => {
|
router.all("/(:port)(/*)?", (req, res) => {
|
||||||
|
@ -33,7 +33,7 @@ router.all("/(:port)(/*)?", (req, res) => {
|
||||||
|
|
||||||
proxy.web(req, res, {
|
proxy.web(req, res, {
|
||||||
ignorePath: true,
|
ignorePath: true,
|
||||||
target: getProxyTarget(req, true),
|
target: getProxyTarget(req, req.args["proxy-path-passthrough"] || false),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -42,6 +42,6 @@ export const wsRouter = WsRouter()
|
||||||
wsRouter.ws("/(:port)(/*)?", ensureAuthenticated, (req) => {
|
wsRouter.ws("/(:port)(/*)?", ensureAuthenticated, (req) => {
|
||||||
proxy.ws(req, req.ws, req.head, {
|
proxy.ws(req, req.ws, req.head, {
|
||||||
ignorePath: true,
|
ignorePath: true,
|
||||||
target: getProxyTarget(req, true),
|
target: getProxyTarget(req, req.args["proxy-path-passthrough"] || false),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue