diff --git a/src/node/app/proxy.ts b/src/node/app/proxy.ts index 14647b8f..a332cc05 100644 --- a/src/node/app/proxy.ts +++ b/src/node/app/proxy.ts @@ -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, }, } diff --git a/src/node/http.ts b/src/node/http.ts index 62abeb07..313ecbeb 100644 --- a/src/node/http.ts +++ b/src/node/http.ts @@ -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,