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; });