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?

1

2 Answers 2

2
app.get('/:path*', function(req, res) {
   console.log(req.params.path + req.params[0]);
});
Sign up to request clarification or add additional context in comments.

1 Comment

hint: req.url is the actual path
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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.