I want to allow any subroute after /example/...
.
Example of valid URLs:
But doing this:
server.get('/example/*', (req, res) => {
// ...
})
Is also allowing /example
without any subroute. And I want to avoid this. How can I do it? Is there any way without using regex?
Thank you so much!
You could simply define two routes - one for /example
and another for all /example
-subroutes, you need to make sure the order is correct though:
app.get('/example', (req, res) => {
// render default page
});
app.get('/example/*', (req, res) => {
// do other stuff
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.