🔨」 fix: added cors to user api

This commit is contained in:
2025-10-15 16:40:28 +02:00
parent 9f194449ac
commit 8d93776444

View File

@ -1,5 +1,6 @@
import fastifyJWT from '@fastify/jwt';
import fastifyCookie from '@fastify/cookie';
import cors from '@fastify/cors'
import Database from 'better-sqlite3';
var env = process.env.NODE_ENV || 'development';
@ -56,6 +57,13 @@ const deleteFriends = database.prepare('DELETE FROM friends WHERE username = ?;'
* @param {import('fastify').FastifyPluginOptions} options
*/
export default async function(fastify, options) {
fastify.register(cors, {
origin: process.ENV.CORS_ORIGIN || 'http://localhost:5173',
credentials: true,
methods: [ "GET", "POST", "DELETE", "OPTIONS" ]
});
fastify.register(fastifyJWT, {
secret: process.env.JWT_SECRET || '123456789101112131415161718192021',
cookie: {