I'm creating a multi-tenant web application and need to dynamically add new customers without having to change my proxy table settings. I was hoping to use RegExp values in the proxy table, but am finding that this doesn't work.
Here's an example of various mappings I need to go to the same backend service:
I was attempting to use a routing table that contains regex values for the sources, such as this:
Unfortunately, this doesn't work. Even though the source string is converted into a RegExp properly, it is also processed by url.parse(). The resulting object doesn't contain the correct values in the properties of the URL object.
So, I'm currently having to hard-code every customer's username into the routing table, like this:
Manually changing this table isn't going to scale long-term. I believe there is a way to dynamically reload the routing table, and I'll probably look at doing that as well. But this table will get very large if I need an entry for every customer. That is not a scalable solution either since this proxy sits in front of every request to my entire infrastructure.
It would be far better if I could just use a RegExp in the table itself. Is there a way to do this and I'm just not aware of it? Would this be of interest to others if I implemented it and submitted a pull request? Any other thoughts?
Checkout 5d515e4, should resolve your issue.