From bba190e4e95eb0ed32d4cd653dc594aaf986dedf Mon Sep 17 00:00:00 2001 From: Matt Aitken Date: Tue, 25 Jul 2023 16:36:19 +0100 Subject: [PATCH] Use apiCors function for the event endpoint too --- apps/webapp/app/routes/api.v1.events.$eventId.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/webapp/app/routes/api.v1.events.$eventId.ts b/apps/webapp/app/routes/api.v1.events.$eventId.ts index 3977531d3..f1bb0e7aa 100644 --- a/apps/webapp/app/routes/api.v1.events.$eventId.ts +++ b/apps/webapp/app/routes/api.v1.events.$eventId.ts @@ -4,6 +4,7 @@ import { cors } from "remix-utils"; import { z } from "zod"; import { prisma } from "~/db.server"; import { authenticateApiRequest } from "~/services/apiAuth.server"; +import { apiCors } from "~/utils/apiCors"; const ParamsSchema = z.object({ eventId: z.string(), @@ -11,14 +12,14 @@ const ParamsSchema = z.object({ export async function loader({ request, params }: LoaderArgs) { if (request.method.toUpperCase() === "OPTIONS") { - return cors(request, json({})); + return apiCors(request, json({})); } const authenticatedEnv = await authenticateApiRequest(request, { allowPublicKey: true, }); if (!authenticatedEnv) { - return cors( + return apiCors( request, json({ error: "Invalid or Missing API key" }, { status: 401 }) ); @@ -46,5 +47,5 @@ export async function loader({ request, params }: LoaderArgs) { }, }); - return cors(request, json(event)); + return apiCors(request, json(event)); }