add cors handling

This commit is contained in:
Darius
2026-02-06 00:00:31 +01:00
parent 34fee498eb
commit 57bbae2919
3 changed files with 29 additions and 0 deletions

View File

@@ -24,12 +24,19 @@ import { SseService } from "@dpu/shared";
import { HomepageService } from "./homepage/service.js";
import { homepageRoutes } from "./homepage/routes.js";
import fastifySSE from "@fastify/sse";
import fastifyCors from "@fastify/cors";
const fastify = Fastify().withTypeProvider<ZodTypeProvider>();
fastify.setValidatorCompiler(validatorCompiler);
fastify.setSerializerCompiler(serializerCompiler);
await fastify.register(fastifyCors, {
origin: ["http://localhost:4321", "https://dariusbag.dev"],
methods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
allowedHeaders: ["Content-Type", "Authorization"],
});
await fastify.register(fastifySwagger, {
openapi: {
info: {