question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pathRewrite not matching regex pattern with variables

See original GitHub issue

I am having an issue getting pathRewrite to match a regex pattern in context to variables in target.

Expected behavior

It should map a regex pattern with expressions (e.g. (.*)) to variables (e.g. $1).

Actual behavior

Proxy is not being created and the Express route yields 404.

Setup

  • http-proxy-middleware: ^0.18.0
  • server: express@^4.16.3

proxy middleware configuration

proxy('/user/(.*)/posts/(.*)', {
  pathRewrite: {
    '^/user/(.*)/posts/(.*)': '/api/user/$1/posts/$2'
  }
})

Is this functionality supported?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:7
  • Comments:15 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
chimuraicommented, Jun 19, 2018

Will consider adding it if more users have to need for this.

0reactions
cdllcommented, Jan 14, 2021

+1

Read more comments on GitHub >

github_iconTop Results From Across the Web

Developers - pathRewrite not matching regex pattern with variables -
I am having an issue getting pathRewrite to match a regex pattern in context to variables in target . Expected behavior. It should...
Read more >
path-to-regexp not matching when passing arguments as ...
When I try to test if path-to-regexp will match a given path I will not get a result when expected, if I pass...
Read more >
Regular expressions in paths - NGINX Ingress Controller
In NGINX, regular expressions follow a first match policy. In order to enable more accurate path matching, ingress-nginx first orders the paths by ......
Read more >
Rewrites - next.config.js
To match a regex path you can wrap the regex in parenthesis after a parameter, for example /blog/:slug(\\d{1,}) will match /blog/123 but not...
Read more >
Modify Outgoing Request Path - Akamai TechDocs
Perl compatible regular expression: Use this to specify match patterns you want ... With the Regular Expression Replacement option, format validation is not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found