浏览代码

chore(http): 拦截器添加Content-Type头

feige996 7 月之前
父节点
当前提交
60e194afc9
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 3 1
      src/http/interceptor.ts

+ 3 - 1
src/http/interceptor.ts

@@ -43,8 +43,9 @@ const httpInterceptor = {
     options.timeout = 60000 // 60s
     // 2. (可选)添加小程序端请求头标识
     options.header = {
-      platform, // 可选,与 uniapp 定义的平台一致,告诉后台来源
       ...options.header,
+      'Content-Type': 'application/json; charset=utf-8',
+      platform, // 可选,与 uniapp 定义的平台一致,告诉后台来源
     }
     // 3. 添加 token 请求头标识
     const tokenStore = useTokenStore()
@@ -53,6 +54,7 @@ const httpInterceptor = {
     if (token) {
       options.header.Authorization = `Bearer ${token}`
     }
+    return options
   },
 }