Browse Source

fix: repair local development post request proxy to https error problem (#63)

vben 4 years ago
parent
commit
34c09fcea8
6 changed files with 16 additions and 9 deletions
  1. 1 0
      .env.development
  2. 6 0
      CHANGELOG.zh_CN.md
  3. 1 1
      package.json
  4. 1 1
      src/App.vue
  5. 3 3
      src/utils/http/axios/index.ts
  6. 4 4
      yarn.lock

+ 1 - 0
.env.development

@@ -6,6 +6,7 @@ VITE_PUBLIC_PATH = /
 
 # Cross-domain proxy, you can configure multiple
 VITE_PROXY=[["/api","http://localhost:3000"]]
+# VITE_PROXY=[["/api","https://vvbin.cn/test"]]
 
 # Delete console
 VITE_DROP_CONSOLE = false

+ 6 - 0
CHANGELOG.zh_CN.md

@@ -1,3 +1,9 @@
+## Wip
+
+### 🐛 Bug Fixes
+
+- 修复本地代理 post 接口到 https 地址超时错误
+
 ## 2.0.0-rc.6 (2020-10-28)
 
 ### ✨ Features

+ 1 - 1
package.json

@@ -89,7 +89,7 @@
     "ts-node": "^9.0.0",
     "typescript": "^4.0.5",
     "vite-plugin-html": "^1.0.0-beta.2",
-    "vite-plugin-mock": "^1.0.4",
+    "vite-plugin-mock": "^1.0.6",
     "vite-plugin-purge-icons": "^0.4.4",
     "vite-plugin-pwa": "^0.1.2",
     "vue-eslint-parser": "^7.1.1",

+ 1 - 1
src/App.vue

@@ -20,7 +20,7 @@
   moment.locale('zh-cn');
 
   export default defineComponent({
-    name: 'App1',
+    name: 'App',
     components: { ConfigProvider },
     setup() {
       useInitAppConfigStore();

+ 3 - 3
src/utils/http/axios/index.ts

@@ -116,20 +116,20 @@ const transform: AxiosTransform = {
       } else {
         // 兼容restful风格
         config.url = config.url + config.params + `?_t=${now}`;
-        config.params = {};
+        config.params = undefined;
       }
     } else {
       if (!isString(config.params)) {
         formatDate && formatRequestDate(config.params);
         config.data = config.params;
-        config.params = {};
+        config.params = undefined;
         if (joinParamsToUrl) {
           config.url = setObjToUrlParams(config.url as string, config.data);
         }
       } else {
         // 兼容restful风格
         config.url = config.url + config.params;
-        config.params = {};
+        config.params = undefined;
       }
     }
     return config;

+ 4 - 4
yarn.lock

@@ -7993,10 +7993,10 @@ vite-plugin-html@^1.0.0-beta.2:
     html-minifier-terser "^5.1.1"
     lodash "^4.17.20"
 
-vite-plugin-mock@^1.0.4:
-  version "1.0.4"
-  resolved "https://registry.npmjs.org/vite-plugin-mock/-/vite-plugin-mock-1.0.4.tgz#56631559afcd77046b058f162b2b5e8f5aaa7b17"
-  integrity sha512-jtos6ri0GAE/abv9VQyVvpPF5yQZaFx7vB7GV9wAZ5TQWqzH9nKUdmVj9ret7lC/oCnpaZn+2twxh4qzkVsd5Q==
+vite-plugin-mock@^1.0.6:
+  version "1.0.6"
+  resolved "https://registry.npmjs.org/vite-plugin-mock/-/vite-plugin-mock-1.0.6.tgz#4f47f193fd48a02c66641fc7242bd5329f99b471"
+  integrity sha512-+IeCiZBgQt2BpKKzYwoB5bWrrUwiksQh/9zWUrsegGw14PXmXtXXmgHr3CkKjyIChZmvuBs1BPieHD8SyBQAGQ==
   dependencies:
     "@rollup/plugin-node-resolve" "^9.0.0"
     chalk "^4.1.0"