From 633704d96e071dde35d51e01eda6654fcd3c8eb9 Mon Sep 17 00:00:00 2001 From: Matti Nannt Date: Mon, 9 Oct 2023 14:12:08 +0200 Subject: [PATCH] fix: add cors to display update endpoint (#1036) --- .../app/api/v1/client/displays/[displayId]/route.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/web/app/api/v1/client/displays/[displayId]/route.ts b/apps/web/app/api/v1/client/displays/[displayId]/route.ts index 4519a208f5..8b0b48e3f0 100644 --- a/apps/web/app/api/v1/client/displays/[displayId]/route.ts +++ b/apps/web/app/api/v1/client/displays/[displayId]/route.ts @@ -4,13 +4,17 @@ import { TDisplayInput, ZDisplayUpdate } from "@formbricks/types/v1/displays"; import { NextResponse } from "next/server"; import { transformErrorToDetails } from "@/lib/api/validator"; +export async function OPTIONS(): Promise { + return responses.successResponse({}, true); +} + export async function PUT( request: Request, { params }: { params: { displayId: string } } ): Promise { const { displayId } = params; if (!displayId) { - return responses.badRequestResponse("Missing displayId"); + return responses.badRequestResponse("Missing displayId", undefined, true); } const displayInput: TDisplayInput = await request.json(); const inputValidation = ZDisplayUpdate.safeParse(displayInput); @@ -24,8 +28,8 @@ export async function PUT( } try { const display = await updateDisplay(displayId, inputValidation.data); - return responses.successResponse(display); + return responses.successResponse(display, true); } catch (error) { - return responses.internalServerErrorResponse(error.message); + return responses.internalServerErrorResponse(error.message, true); } }