Skip to content

How to do a wildcard proxy with 3.0? #1003

Answered by leoc-22
SantoJambit asked this question in Q&A
Discussion options

You must be logged in to vote

just encountered this issue this week and my solution is to use pathRewrite to return path.

in my use case, it was to proxy anything with /api/* to the target url:

app.use(
  "/api",
  createProxyMiddleware({
      pathRewrite: (path) => path
      target: "http://localhost:4200",
      changeOrigin: true,
  })
);

you can probably also use:

on: {
  proxyReq: (proxyReq, req, res) => {}
}

to get the path after the base url and attach to the target base url.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@SantoJambit
Comment options

Answer selected by SantoJambit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants