Browse Source

feat: 接口抽取api前缀通过配置实现

windyeasy 5 months ago
parent
commit
5d1b0a1552
3 changed files with 9 additions and 8 deletions
  1. 2 0
      .env.development
  2. 7 7
      src/services/modules/registory.js
  3. 0 1
      vite.config.js

+ 2 - 0
.env.development

@@ -1 +1,3 @@
+# VITE_BASE_URL = "/api/"
+
 VITE_BASE_URL = ""

+ 7 - 7
src/services/modules/registory.js

@@ -3,17 +3,17 @@ import request from "..";
 // 发送验证码
 export function sendVerificationCodeRequest(phone) {
   return request.get({
-    url: "/api/v1/common/send-validate",
+    url: "/v1/common/send-validate",
     data: {
-      phone
-    }
-  })
+      phone,
+    },
+  });
 }
 
 // 注册用户
 export function registroyUser(info) {
   return request.post({
-    url: "/api/v1/user-register",
-    data: info
-  })
+    url: "/v1/user-register",
+    data: info,
+  });
 }

+ 0 - 1
vite.config.js

@@ -14,7 +14,6 @@ export default defineConfig({
         target: "http://47.109.38.72:10887/",
         secure: false, // 如果是https接口,需要配置这个参数
         changeOrigin: true, // 如果接口跨域,需要进行这个参数配置
-        rewrite: (path) => path.replace(/^\/demo/, "/demo"),
       },
       "/v1": {
         // target: 'http://kcapp.gzzzyd.com/', // 接口的域名