Monday 12 June 2017

ExpressJS : Modify route in a middleware

Running an express app which for example has a route like /home and others. Now I want to change url to /en/home, /sp/home etc.

My requirement is to map these routes from /en/home to /home and similarly /sp/home to /home and add a header on request object on basis of /en and /sp

I want to write a middleware which will modify routes and extract information from it on basis of route as mentioned above.

I can use regex to do the second part but could not find a way to modify route on the fly.



via Aman Gupta

No comments:

Post a Comment