diff --git a/src/api/admin/sys-user.js b/src/api/admin/sys-user.js index 07c1d0ae..7fb28592 100644 --- a/src/api/admin/sys-user.js +++ b/src/api/admin/sys-user.js @@ -121,7 +121,8 @@ export function uploadAvatar(data) { return request({ url: '/api/v1/user/avatar', method: 'post', - data: data + data: data, + headers: { 'Content-Type': 'multipart/form-data' } }) } diff --git a/src/utils/request.js b/src/utils/request.js index c61c35d1..bd38c19f 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -20,7 +20,10 @@ service.interceptors.request.use( // ['X-Token'] is a custom headers key // please modify it according to the actual situation config.headers['Authorization'] = 'Bearer ' + getToken() - config.headers['Content-Type'] = 'application/json' + // while not set Content-Type, default is application/json + if (!config.headers['Content-Type']) { + config.headers['Content-Type'] = 'application/json' + } } return config },