T
T
Torento203452021-07-16 01:04:07
Express.js
Torento20345, 2021-07-16 01:04:07

How to redirect to 404 when there are no use names?

There is where use
app.use("/", ...)
app.use("/about", ...)
app.use("/info", ...)

And how to process those requests that are not, to give 404?
After all, all requests are *, and then it will block all these, and I only need those that the expert did not find in use.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Neverov, 2021-07-16
@Torento20345

Connect the last route *.
Express will search in order, if it doesn't find a match, it will route to *

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question