Reputation:
I'm fairly new to node js and I need to develop some kind of reverse proxy in node JS which is getting some URL with path and I need to route the call to rest APi according to the URL (identify the URL by some regex),there is some example or some module which I can use which is open source. Example and direction how to do it right will be very helpful! :)
Upvotes: 0
Views: 91
Reputation: 3087
For example
url = "http://example.com/profile"
req.get('host')
will give the hostname like http://example.com.
in req.url
you can get url /profile
use expressjs for routing http://expressjs.com/ For example
app.get('/profile', function (req, res) {
res.send('GET request to homepage');//or render profile page
});
Upvotes: 1