From 89dd4321e37596e1567990fd881804cf5c02efca Mon Sep 17 00:00:00 2001 From: ThuanHipp <88172491+VanThuan76@users.noreply.github.com> Date: Sat, 11 Jan 2025 20:50:40 +0700 Subject: [PATCH] #fix: thuanvv fix cors --- src/web/app.ts | 4 +++- src/web/server.ts | 7 ------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/web/app.ts b/src/web/app.ts index 88766fa..1545c8a 100644 --- a/src/web/app.ts +++ b/src/web/app.ts @@ -21,7 +21,9 @@ export default async function makeApp(fastify: FastifyInstance) { // Configure CORS await fastify.register(Cors, { - origin: false, // TODO: Set this to a valid origin + origin: '*', + methods: ['GET', 'POST', 'PUT', 'DELETE'], + allowedHeaders: ['Content-Type', 'Authorization'], }); // Auto-load plugins diff --git a/src/web/server.ts b/src/web/server.ts index 21fb7ac..876b729 100644 --- a/src/web/server.ts +++ b/src/web/server.ts @@ -1,5 +1,4 @@ import dotenv from 'dotenv'; -import cors from '@fastify/cors'; import Fastify from 'fastify'; import app from './app'; @@ -13,12 +12,6 @@ async function start() { }, }); - await fastify.register(cors, { - origin: '*', - methods: ['GET', 'POST', 'PUT', 'DELETE'], - allowedHeaders: ['Content-Type', 'Authorization'], - }); - await app(fastify); const applicationConfig = fastify.diContainer.cradle.config;