i can’t call authentication, when try to check auth
es
fastify.get<{ Querystring: IQuerystring; Reply: IReplyCurrent }>(
'/at/api',
{
onRequest: [fastify.authentication()],
},
---
// plugins/route.ts
export async function authRoute(fastify: FastifyInstance, option: object, done: () => void) {
// #region addone to fastify
fastify.register(import('@fastify/jwt'), {
secret: 'secret-key',
});
// index.ts
fastify.register(authRoute, { prefix: '/auth' });
fastifyPlugin(async function (fastify, opts, done) {
fastify.decorate('authentication', async (request, reply) => {
try {
await request.jwtVerify();
} catch (error) {
reply.code(401).send({ error: 'Unauthorized' });
}
});
done();
});
I won check if client it’s call api ase authenticate and if autenticate is expired i won use refresh token for create another