浏览代码

添加请求头Ds-Host

seimin 8 月之前
父节点
当前提交
cb0adfdd86
共有 1 个文件被更改,包括 8 次插入2 次删除
  1. 8 2
      http/http.js

+ 8 - 2
http/http.js

@@ -1,6 +1,10 @@
1
 // #ifdef H5
1
 // #ifdef H5
2
 import wx from 'weixin-jsapi'
2
 import wx from 'weixin-jsapi'
3
 // #endif
3
 // #endif
4
+let dsHost = "";
5
+// #ifdef H5
6
+dsHost = location.hostname;
7
+// #endif
4
 
8
 
5
 export const path = `${location.origin}/service`
9
 export const path = `${location.origin}/service`
6
 // get方法
10
 // get方法
@@ -11,7 +15,8 @@ export function get(url, data = {}) {
11
       url,
15
       url,
12
       data,
16
       data,
13
       header: {
17
       header: {
14
-        'Cache-Control': 'no-cache'
18
+        'Cache-Control': 'no-cache',
19
+        'Ds-Host': dsHost,
15
       },
20
       },
16
       success(res) {
21
       success(res) {
17
         if(res.statusCode === 200){
22
         if(res.statusCode === 200){
@@ -43,7 +48,8 @@ export function post(url, data = {}) {
43
       url,
48
       url,
44
       data,
49
       data,
45
       header: {
50
       header: {
46
-        'Cache-Control': 'no-cache'
51
+        'Cache-Control': 'no-cache',
52
+        'Ds-Host': dsHost,
47
       },
53
       },
48
       success(res) {
54
       success(res) {
49
         if(res.statusCode === 200){
55
         if(res.statusCode === 200){