From ba94adb8d7b8ba8697252460885c0f8127fdf8e1 Mon Sep 17 00:00:00 2001 From: Ryan Moon Date: Sun, 29 Mar 2026 11:23:21 -0500 Subject: [PATCH] Fix DELETE sending empty JSON body, add repair_note to allowed file entity types API client no longer sets Content-Type: application/json on requests without a body (fixes DELETE 400 errors). Added repair_note to the allowed entityTypes whitelist for file uploads so photos can be attached to repair notes. --- packages/admin/src/lib/api-client.ts | 6 ++++-- packages/backend/src/routes/v1/files.ts | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/admin/src/lib/api-client.ts b/packages/admin/src/lib/api-client.ts index be530e4..5ec8ac1 100644 --- a/packages/admin/src/lib/api-client.ts +++ b/packages/admin/src/lib/api-client.ts @@ -15,8 +15,10 @@ class ApiError extends Error { async function request(method: string, path: string, body?: unknown): Promise { const { token } = useAuthStore.getState() - const headers: Record = { - 'Content-Type': 'application/json', + const headers: Record = {} + + if (body) { + headers['Content-Type'] = 'application/json' } if (token) { diff --git a/packages/backend/src/routes/v1/files.ts b/packages/backend/src/routes/v1/files.ts index aacb84c..5bacdfe 100644 --- a/packages/backend/src/routes/v1/files.ts +++ b/packages/backend/src/routes/v1/files.ts @@ -42,7 +42,7 @@ export const fileRoutes: FastifyPluginAsync = async (app) => { } // Validate entityType is a known type - const allowedEntityTypes = ['user', 'member', 'member_identifier', 'product', 'rental_agreement', 'repair_ticket'] + const allowedEntityTypes = ['user', 'member', 'member_identifier', 'product', 'rental_agreement', 'repair_ticket', 'repair_note'] if (!allowedEntityTypes.includes(entityType)) { throw new ValidationError(`Invalid entityType: ${entityType}`) }