From 34f00d9f001755c1908a15768005b709b09fe2f8 Mon Sep 17 00:00:00 2001 From: DJP Date: Wed, 10 Dec 2025 23:16:32 -0500 Subject: [PATCH] FIX: Allow axios to auto-detect Content-Type for FormData uploads --- frontend/lib/api.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/frontend/lib/api.ts b/frontend/lib/api.ts index c167dd4..103a28b 100644 --- a/frontend/lib/api.ts +++ b/frontend/lib/api.ts @@ -2,15 +2,16 @@ import axios from 'axios'; const api = axios.create({ baseURL: process.env.NEXT_PUBLIC_API_URL || '/api/v1', - headers: { - 'Content-Type': 'application/json', - }, withCredentials: true, // Send cookies with requests }); -// Request interceptor - cookies are sent automatically with withCredentials +// Request interceptor - set Content-Type based on data type api.interceptors.request.use((config) => { - // Token is sent via cookie, no need to add Authorization header + // Let axios auto-detect Content-Type for FormData + // Only set application/json for non-FormData requests + if (!(config.data instanceof FormData)) { + config.headers['Content-Type'] = 'application/json'; + } return config; });