From 375482e654a01615683867e732ac9e458c7cbe74 Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Sun, 16 Aug 2026 20:17:42 -0300 Subject: feat: upload yaba src Signed-off-by: Lucas Faria Mendes --- api/src/plugins/cors.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 api/src/plugins/cors.ts (limited to 'api/src/plugins') diff --git a/api/src/plugins/cors.ts b/api/src/plugins/cors.ts new file mode 100644 index 0000000..5398e39 --- /dev/null +++ b/api/src/plugins/cors.ts @@ -0,0 +1,18 @@ +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; -- cgit v1.2.3