🔨」 fix(cors issue): should be working as expected

This commit is contained in:
2025-09-24 14:12:05 +02:00
parent 4900db1e98
commit 1d2bb02e65
3 changed files with 18 additions and 0 deletions

View File

@ -2,6 +2,7 @@
"dependencies": {
"@avalabs/avalanchejs": "^5.0.0",
"@fastify/cookie": "^11.0.2",
"@fastify/cors": "^11.1.0",
"@fastify/env": "^5.0.2",
"@fastify/jwt": "^9.1.0",
"axios": "^1.10.0",

11
pnpm-lock.yaml generated
View File

@ -14,6 +14,9 @@ importers:
'@fastify/cookie':
specifier: ^11.0.2
version: 11.0.2
'@fastify/cors':
specifier: ^11.1.0
version: 11.1.0
'@fastify/env':
specifier: ^5.0.2
version: 5.0.2
@ -255,6 +258,9 @@ packages:
'@fastify/cookie@11.0.2':
resolution: {integrity: sha512-GWdwdGlgJxyvNv+QcKiGNevSspMQXncjMZ1J8IvuDQk0jvkzgWWZFNC2En3s+nHndZBGV8IbLwOI/sxCZw/mzA==}
'@fastify/cors@11.1.0':
resolution: {integrity: sha512-sUw8ed8wP2SouWZTIbA7V2OQtMNpLj2W6qJOYhNdcmINTu6gsxVYXjQiM9mdi8UUDlcoDDJ/W2syPo1WB2QjYA==}
'@fastify/deepmerge@2.0.2':
resolution: {integrity: sha512-3wuLdX5iiiYeZWP6bQrjqhrcvBIf0NHbQH1Ur1WbHvoiuTYUEItgygea3zs8aHpiitn0lOB8gX20u1qO+FDm7Q==}
@ -1758,6 +1764,11 @@ snapshots:
cookie: 1.0.2
fastify-plugin: 5.0.1
'@fastify/cors@11.1.0':
dependencies:
fastify-plugin: 5.0.1
toad-cache: 3.7.0
'@fastify/deepmerge@2.0.2': {}
'@fastify/env@5.0.2':

View File

@ -1,5 +1,6 @@
import fastifyJWT from '@fastify/jwt';
import fastifyCookie from '@fastify/cookie';
import cors from '@fastify/cors'
import { register } from './register.js';
import { login } from './login.js';
@ -22,6 +23,11 @@ authDB.prepareDB();
*/
export default async function(fastify, options) {
fastify.register(cors, {
origin: "*",
methods: ["GET", "POST", "DELETE"]
});
fastify.register(fastifyJWT, {
secret: process.env.JWT_SECRET || '123456789101112131415161718192021',
cookie: {