diff --git a/index.js b/index.js index d5e3108..e2159af 100644 --- a/index.js +++ b/index.js @@ -27,7 +27,7 @@ function fastifyBearerAuth (fastify, options, done) { try { if (options.addHook === true) { - fastify.addHook('onRequest', verifyBearerAuthFactory(options)) + fastify.addHook('preHandler', verifyBearerAuthFactory(options)) } else { fastify.decorate('verifyBearerAuthFactory', verifyBearerAuthFactory) fastify.decorate('verifyBearerAuth', verifyBearerAuthFactory(options))