Express use fails if one path is a substring of another

69 Views Asked by At

I'm configuring a proxy (http-proxy-middleware) for dev server, using the following configuration

app.use(
  /^\/(pathone|pathtwo|pathonetwo)/,
  createProxyMiddleware(...)
)

This matches /pathone and /pathtwo correctly, but /pathonetwo is completely ignored and loads the index page instead. How to avoid this? I can't add a $ at the end because I also need to match paths like /load/1.

Edit: using an array of paths (['/pathone', '/pathtwo', '/pathonetwo']) works as expected. Is there a bug in how it treats regexps?

0

There are 0 best solutions below