From dca2031a38996a6283ec7d692cc7a833682d356d Mon Sep 17 00:00:00 2001 From: hailin Date: Fri, 6 Mar 2026 11:03:00 -0800 Subject: [PATCH] fix(http-client): delete Content-Type in request interceptor when data is FormData Instance-level default Content-Type: application/json was overriding browser's auto-generated multipart/form-data boundary. Remove it for FormData so browser sets correct Content-Type with boundary. Co-Authored-By: Claude Sonnet 4.6 --- frontend/admin-web/src/infrastructure/http/http.client.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/admin-web/src/infrastructure/http/http.client.ts b/frontend/admin-web/src/infrastructure/http/http.client.ts index efabfaf..009f92c 100644 --- a/frontend/admin-web/src/infrastructure/http/http.client.ts +++ b/frontend/admin-web/src/infrastructure/http/http.client.ts @@ -20,7 +20,7 @@ class HttpClient { headers: { 'Content-Type': 'application/json' }, }); - // Request 拦截器:注入 Bearer token + // Request 拦截器:注入 Bearer token;FormData 时删除 Content-Type 让浏览器自动带 boundary this.client.interceptors.request.use((config) => { if (typeof window !== 'undefined') { try { @@ -35,6 +35,9 @@ class HttpClient { // ignore parse errors } } + if (config.data instanceof FormData) { + delete config.headers['Content-Type']; + } return config; });