mirror of
https://github.com/KeyZox71/knl_meowscendence.git
synced 2025-12-31 21:56:41 +01:00
「🔨」 fix(cors): fixed some things.
This commit is contained in:
@ -1,5 +1,6 @@
|
|||||||
import fastifyJWT from '@fastify/jwt';
|
import fastifyJWT from '@fastify/jwt';
|
||||||
import fastifyCookie from '@fastify/cookie';
|
import fastifyCookie from '@fastify/cookie';
|
||||||
|
import cors from '@fastify/cors';
|
||||||
|
|
||||||
import { register } from './register.js';
|
import { register } from './register.js';
|
||||||
import { login } from './login.js';
|
import { login } from './login.js';
|
||||||
@ -24,6 +25,12 @@ authDB.prepareDB();
|
|||||||
*/
|
*/
|
||||||
export default async function(fastify, options) {
|
export default async function(fastify, options) {
|
||||||
|
|
||||||
|
fastify.register(cors, {
|
||||||
|
origin: process.env.CORS_ORIGIN || 'http://localhost:5173',
|
||||||
|
credentials: true,
|
||||||
|
methods: [ "GET", "POST", "PATCH", "DELETE", "OPTIONS" ]
|
||||||
|
});
|
||||||
|
|
||||||
fastify.register(fastifyJWT, {
|
fastify.register(fastifyJWT, {
|
||||||
secret: process.env.JWT_SECRET || '123456789101112131415161718192021',
|
secret: process.env.JWT_SECRET || '123456789101112131415161718192021',
|
||||||
cookie: {
|
cookie: {
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import fastifyJWT from '@fastify/jwt';
|
import fastifyJWT from '@fastify/jwt';
|
||||||
import fastifyCookie from '@fastify/cookie';
|
import fastifyCookie from '@fastify/cookie';
|
||||||
import Database from 'better-sqlite3';
|
import Database from 'better-sqlite3';
|
||||||
|
import cors from '@fastify/cors';
|
||||||
|
|
||||||
import { gUsers } from './gUsers.js';
|
import { gUsers } from './gUsers.js';
|
||||||
import { gUser } from './gUser.js';
|
import { gUser } from './gUser.js';
|
||||||
@ -150,6 +151,11 @@ export default async function(fastify, options) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
fastify.register(fastifyCookie);
|
fastify.register(fastifyCookie);
|
||||||
|
fastify.register(cors, {
|
||||||
|
origin: process.env.CORS_ORIGIN || 'http://localhost:5173',
|
||||||
|
credentials: true,
|
||||||
|
methods: [ "GET", "POST", "PATCH", "DELETE", "OPTIONS" ]
|
||||||
|
});
|
||||||
|
|
||||||
fastify.addContentTypeParser(
|
fastify.addContentTypeParser(
|
||||||
['image/jpeg', 'image/png', 'image/gif', 'image/webp'],
|
['image/jpeg', 'image/png', 'image/gif', 'image/webp'],
|
||||||
|
|||||||
Reference in New Issue
Block a user