Refactor hostServer assignment in PUT request to handle null values correctly

This commit is contained in:
headlessdev 2025-04-18 23:48:29 +02:00
parent 42e584a381
commit f2535cd2b9

View File

@ -25,11 +25,18 @@ export async function PUT(request: NextRequest) {
return NextResponse.json({ error: "Server not found" }, { status: 404 });
}
let newHostServer = hostServer;
if (hostServer === null) {
newHostServer = 0;
} else {
newHostServer = hostServer;
}
const updatedServer = await prisma.server.update({
where: { id },
data: {
host,
hostServer,
hostServer: newHostServer,
name,
os,
ip,