NestJS · Middle · Question 2 of 75

Why should authentication be a guard rather than middleware?

Explanation

Middleware doesn't know which route handler will run. Guards are designed for 'may this request proceed?' decisions.

Further reading

Problem with a question

NestJS · Middle · question 2

Test yourself

Take the NestJS · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz