From 99f98508af269ab1cbead05496611c810ba3cd60 Mon Sep 17 00:00:00 2001 From: Arthur Barre Date: Mon, 16 Dec 2024 15:12:53 +0100 Subject: [PATCH] add cors --- backend/src/index.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/backend/src/index.js b/backend/src/index.js index 832f240..9fa4855 100644 --- a/backend/src/index.js +++ b/backend/src/index.js @@ -11,11 +11,23 @@ const purchaseRoutes = require('./routes/purchases') const artistRoutes = require('./routes/artists') const userRoutes = require('./routes/users') const clientRoutes = require('./routes/clients') -const prisma = new PrismaClient() +// const prisma = new PrismaClient() +const prisma = new PrismaClient({ + datasources: { + db: { + url: process.env.DATABASE_URL || 'file:./data/db.sqlite' + } + } +}) const fastify = Fastify({ logger: true }) // Plugins -fastify.register(cors) +fastify.register(cors, { + origin: ['http://localhost:8090'], + credentials: true, + methods: ['GET', 'PUT', 'POST', 'DELETE', 'OPTIONS'], + allowedHeaders: ['Content-Type', 'Authorization'] +}) // Middleware JWT const JWT_SECRET = 'votre_secret_jwt'