mirror of
https://github.com/formbricks/formbricks.git
synced 2026-01-06 05:40:02 -06:00
fix: add cors to display update endpoint (#1036)
This commit is contained in:
@@ -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<NextResponse> {
|
||||
return responses.successResponse({}, true);
|
||||
}
|
||||
|
||||
export async function PUT(
|
||||
request: Request,
|
||||
{ params }: { params: { displayId: string } }
|
||||
): Promise<NextResponse> {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user