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 <noreply@anthropic.com>
This commit is contained in:
parent
fc85983b43
commit
dca2031a38
|
|
@ -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;
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue