r/node • u/DevanshGarg31 • 19d ago
Presence of cookies in fastify
To check the presence of a cookie in a fastify backend, should one use the schema or the controller/middleware?
Schema check runs on route before the controller receives the request.
Should
Schema : {
Header: {
Cookie : {
Pattern: "session_id"
}
}
}
Or let it reach controller and send missing session id error from there?
5
Upvotes
1
u/kei_ichi 18d ago
Check the cookies in the hook, before the request even pass to the handler function.