fastify / fastify-jwt

JWT utils for Fastify
MIT License
512 stars 99 forks source link

Fix onRequest hook documentation #302

Closed mattiapv closed 1 year ago

mattiapv commented 1 year ago

Added missing async and await keywords, try...catch block. This prevents server crashes caused by missing await on jwtVerify() function.

mattiapv commented 1 year ago

None of this are needed, why did you add them?

Because without awaiting jwtVerify() the server crash.

You can try the cookie or the onlyCookie example.

If you make a call to http://localhost:3000/verifyCookie the server crash.

If I add await request.jwtVerify(), I receive the correct error (FST_JWT_NO_AUTHORIZATION_IN_HEADER) and the server doesn't crash.