maotao 9 miesięcy temu
rodzic
commit
95e1bded2d
2 zmienionych plików z 12 dodań i 5 usunięć
  1. 10 3
      http/http.js
  2. 2 2
      manifest.json

+ 10 - 3
http/http.js

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

+ 2 - 2
manifest.json

@@ -62,13 +62,13 @@
62
         "devServer" : {
62
         "devServer" : {
63
             "proxy" : {
63
             "proxy" : {
64
                 "/service" : {
64
                 "/service" : {
65
-                    "target" : "http://192.168.3.111", //请求的目标域名
65
+                    "target" : "http://192.168.3.108", //请求的目标域名
66
 										// "target" : "http://192.168.4.163", //宋程玉本地
66
 										// "target" : "http://192.168.4.163", //宋程玉本地
67
                     "changeOrigin" : true, //是否跨域
67
                     "changeOrigin" : true, //是否跨域
68
                     "secure" : false
68
                     "secure" : false
69
                 },
69
                 },
70
                 "/file" : {
70
                 "/file" : {
71
-                    "target" : "http://192.168.3.111", //请求的目标域名
71
+                    "target" : "http://192.168.3.108", //请求的目标域名
72
                     "changeOrigin" : true, //是否跨域
72
                     "changeOrigin" : true, //是否跨域
73
                     "secure" : false
73
                     "secure" : false
74
                 }
74
                 }