I have a server action which I'm calling in a client component when submitting a form. Here is the code:
export async function editIdeation({
body
}: EditIdeationProps): Promise<EditIdeationResponse> {
const token = getCookie();
try {
const data = await PATCH<EditIdeationBody, EditIdeationResponse>(
url,
token,
"default",
body
);
revalidatePath(url);
return data;
} catch (error: unknown) {
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error("An unknown error occurred");
}
}
}
In development, I get the error message properly, however in production I get this message instead: An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.
How can I get the actual error message from the api in production?