File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ export class ProxyHttpProvider extends HttpProvider {
24
24
const port = route . base . replace ( / ^ \/ / , "" )
25
25
return {
26
26
proxy : {
27
- base : `${ route . providerBase } /${ port } ` ,
27
+ strip : `${ route . providerBase } /${ port } ` ,
28
28
port,
29
29
} ,
30
30
}
@@ -35,7 +35,7 @@ export class ProxyHttpProvider extends HttpProvider {
35
35
const port = route . base . replace ( / ^ \/ / , "" )
36
36
return {
37
37
proxy : {
38
- base : `${ route . providerBase } /${ port } ` ,
38
+ strip : `${ route . providerBase } /${ port } ` ,
39
39
port,
40
40
} ,
41
41
}
Original file line number Diff line number Diff line change @@ -36,9 +36,13 @@ export type Query = { [key: string]: string | string[] | undefined }
36
36
37
37
export interface ProxyOptions {
38
38
/**
39
- * A base path to strip from from the request before proxying if necessary.
39
+ * A path to strip from from the beginning of the request before proxying
40
40
*/
41
- base ?: string
41
+ strip ?: string
42
+ /**
43
+ * A path to add to the beginning of the request before proxying.
44
+ */
45
+ prepend ?: string
42
46
/**
43
47
* The port to proxy.
44
48
*/
@@ -826,10 +830,11 @@ export class HttpServer {
826
830
// sure how best to get this information to the `proxyRes` event handler.
827
831
// For now I'm sticking it on the request object which is passed through to
828
832
// the event.
829
- ; ( request as ProxyRequest ) . base = options . base
833
+ ; ( request as ProxyRequest ) . base = options . strip
830
834
831
835
const isHttp = response instanceof http . ServerResponse
832
- const path = options . base ? route . fullPath . replace ( options . base , "" ) : route . fullPath
836
+ const base = options . strip ? route . fullPath . replace ( options . strip , "" ) : route . fullPath
837
+ const path = normalize ( "/" + ( options . prepend || "" ) + "/" + base , true )
833
838
const proxyOptions : proxy . ServerOptions = {
834
839
changeOrigin : true ,
835
840
ignorePath : true ,
You can’t perform that action at this time.
0 commit comments