Skip to content

preHandler vs onRequest #3772

Closed Answered by Eomm
gajus asked this question in Q&A
Mar 14, 2022 · 1 comments · 9 replies
Discussion options

You must be logged in to vote

The main difference is that the onRequest has not the body payload parsed, the preHandler has it
https://www.fastify.io/docs/latest/Reference/Lifecycle/#lifecycle

So, do you need to manipulate the body? Use preHandler
Do you need to know that a request has come into the server? Use onRequest

Replies: 1 comment 9 replies

Comment options

You must be logged in to vote
9 replies
@steven-gpa
Comment options

@Uzlopak
Comment options

@steven-gpa
Comment options

@Uzlopak
Comment options

@steven-gpa
Comment options

Answer selected by RafaelGSS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants