Browse Source

请求头添加Ds-Host

seimin 8 months ago
parent
commit
9eff5063c0
1 changed files with 9 additions and 4 deletions
  1. 9 4
      http/http.js

+ 9 - 4
http/http.js

@@ -4,11 +4,13 @@ import wx from 'weixin-jsapi'
4
 // #endif
4
 // #endif
5
 let path = "";
5
 let path = "";
6
 let appIp = "";
6
 let appIp = "";
7
+let dsHost = "";
7
 // #ifdef H5
8
 // #ifdef H5
8
 let domainName = location.host; //域名+端口
9
 let domainName = location.host; //域名+端口
9
 let protocolName = document.location.protocol; //http协议
10
 let protocolName = document.location.protocol; //http协议
10
 let wsName = protocolName === 'http:' ? 'ws' : 'wss'; //ws协议
11
 let wsName = protocolName === 'http:' ? 'ws' : 'wss'; //ws协议
11
-path = `${protocolName}//${domainName}/service`
12
+path = `${protocolName}//${domainName}/service`;
13
+dsHost = location.hostname;
12
 // #endif
14
 // #endif
13
 uni.setStorageSync('path', path);
15
 uni.setStorageSync('path', path);
14
 
16
 
@@ -20,7 +22,8 @@ export function get(url, data = {}) {
20
       url,
22
       url,
21
       data,
23
       data,
22
       header: {
24
       header: {
23
-        'Cache-Control': 'no-cache'
25
+        'Cache-Control': 'no-cache',
26
+        'Ds-Host': dsHost,
24
       },
27
       },
25
       success(res) {
28
       success(res) {
26
         resolve(res.data);
29
         resolve(res.data);
@@ -47,7 +50,8 @@ export function post(url, data = {}) {
47
       url,
50
       url,
48
       data,
51
       data,
49
       header: {
52
       header: {
50
-        'Cache-Control': 'no-cache'
53
+        'Cache-Control': 'no-cache',
54
+        'Ds-Host': dsHost,
51
       },
55
       },
52
       success(res) {
56
       success(res) {
53
         resolve(res.data);
57
         resolve(res.data);
@@ -71,7 +75,8 @@ export function deleteIt(url, data = {}) {
71
       url,
75
       url,
72
       data,
76
       data,
73
       header: {
77
       header: {
74
-        'Cache-Control': 'no-cache'
78
+        'Cache-Control': 'no-cache',
79
+        'Ds-Host': dsHost,
75
       },
80
       },
76
       success(res) {
81
       success(res) {
77
         resolve(res.data);
82
         resolve(res.data);