2

I need to save the full path as a string for further processing, i.e.

localhost:3000/abc/xyz/etc

would give me:

"/abc/xyz/etc"

I tried

app.get('/.+:path', function(req, res) {
   console.log('path:'+req.params[0]);
});

But it does not work. Any ideas?

user3601578
  • 1,310
  • 1
  • 18
  • 29

2 Answers2

2
app.get('/:path*', function(req, res) {
   console.log(req.params.path + req.params[0]);
});
Anthony C
  • 2,117
  • 2
  • 15
  • 26
0

It's unclear what's the route and what's the params but this is a good starting point:

app.get('/abc/:path', function(req, res) {
   console.log('path:'+req.params.path);
});

If you call localhost:3000/abc/xyz You will get path:xyz

michelem
  • 14,430
  • 5
  • 50
  • 66