I have, ```js // server.js await fastify.register(require('./routes/user.routes'), {prefix: '/user'}); ``` ```js // user.route.js contains: const fp = require('fastify-plugin'); async function userRoutes(fastify, options) { fastify.get('/me', async (request, reply) => { if (!request.session || !request.session.user) { return reply.code(401).send({ error: 'Not authenticated' }); } reply.send(request.session.user); }); fastify.post('/logout', { preHandler: [fastify.authenticate] }, async (request, reply) => { if (request.session) { request.session.destroy(); } reply.send({ message: 'Logged out' }); }); } module.exports = fp(userRoutes); ``` but when i go to /prefix/me, i get => 404 error, page not found but when i go to /me, i get => 401 not authenticated (as expected) on package.json: ```js "fastify": "^5.3.3", "fastify-plugin": "^5.0.1", "@fastify/cookie": "^11.0.2", "@fastify/cors": "^11.0.1", "@fastify/session": "^11.1.0", "@fastify/swagger": "^9.5.1", "@fastify/swagger-ui": "^5.2.2", ```
Activity
inyourtime commentedon May 21, 2025
If you use fastify-plugin, the
prefixoption will be ignored. See Plugin Options for more details.Just do: