mirror of https://git.tuxpa.in/a/code-server.git
Add the ability to prepend to the proxy path
This is for applications like Jupyter that aren't base path agnostic.
This commit is contained in:
parent
c67d31580f
commit
7c2ca7d03e
|
@ -24,7 +24,7 @@ export class ProxyHttpProvider extends HttpProvider {
|
|||
const port = route.base.replace(/^\//, "")
|
||||
return {
|
||||
proxy: {
|
||||
base: `${route.providerBase}/${port}`,
|
||||
strip: `${route.providerBase}/${port}`,
|
||||
port,
|
||||
},
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ export class ProxyHttpProvider extends HttpProvider {
|
|||
const port = route.base.replace(/^\//, "")
|
||||
return {
|
||||
proxy: {
|
||||
base: `${route.providerBase}/${port}`,
|
||||
strip: `${route.providerBase}/${port}`,
|
||||
port,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -36,9 +36,13 @@ export type Query = { [key: string]: string | string[] | undefined }
|
|||
|
||||
export interface ProxyOptions {
|
||||
/**
|
||||
* A base path to strip from from the request before proxying if necessary.
|
||||
* A path to strip from from the beginning of the request before proxying
|
||||
*/
|
||||
base?: string
|
||||
strip?: string
|
||||
/**
|
||||
* A path to add to the beginning of the request before proxying.
|
||||
*/
|
||||
prepend?: string
|
||||
/**
|
||||
* The port to proxy.
|
||||
*/
|
||||
|
@ -826,10 +830,11 @@ export class HttpServer {
|
|||
// sure how best to get this information to the `proxyRes` event handler.
|
||||
// For now I'm sticking it on the request object which is passed through to
|
||||
// the event.
|
||||
;(request as ProxyRequest).base = options.base
|
||||
;(request as ProxyRequest).base = options.strip
|
||||
|
||||
const isHttp = response instanceof http.ServerResponse
|
||||
const path = options.base ? route.fullPath.replace(options.base, "") : route.fullPath
|
||||
const base = options.strip ? route.fullPath.replace(options.strip, "") : route.fullPath
|
||||
const path = normalize("/" + (options.prepend || "") + "/" + base, true)
|
||||
const proxyOptions: proxy.ServerOptions = {
|
||||
changeOrigin: true,
|
||||
ignorePath: true,
|
||||
|
|
Loading…
Reference in New Issue