import cors from '@fastify/cors'; import type { FastifyPluginAsync } from 'fastify'; /** * Plugin de CORS para o Fastify. * Em produção, substitua o `origin: true` pelo domínio/IP do seu app mobile * ou pelo endereço da sua VPS. */ const corsPlugin: FastifyPluginAsync = async (fastify) => { fastify.register(cors, { // Em dev: aceita qualquer origem // Em prod: restrinja para o IP/domínio conhecido origin: process.env.CORS_ORIGIN ?? true, methods: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'], }); }; export default corsPlugin;