冯诚 2 lat temu
rodzic
commit
4a8c29f28b
3 zmienionych plików z 13 dodań i 3 usunięć
  1. 2 2
      .env
  2. 2 1
      src/service/request.ts
  3. 9 0
      vite.config.ts

+ 2 - 2
.env

@@ -1,2 +1,2 @@
-VITE_API_BASE=https://mockapi.eolink.com/9A5KfUCbe99f2b17204d98bfebe7a77757ce256af3e4e90
-#VITE_API_BASE=http://t.ptcrepair.com.au/care
+#VITE_API_BASE=https://mockapi.eolink.com/9A5KfUCbe99f2b17204d98bfebe7a77757ce256af3e4e90
+VITE_API_BASE=http://t.ptcrepair.com.au/care

+ 2 - 1
src/service/request.ts

@@ -18,7 +18,8 @@ interface ResponseData<T = any> {
 }
 
 const _axios = axios.create({
-  baseURL: import.meta.env.VITE_API_BASE,
+  // baseURL: import.meta.env.VITE_API_BASE,
+  baseURL: '/api',
 })
 const cancelMethods: Record<string, Canceler> = {}
 

+ 9 - 0
vite.config.ts

@@ -21,4 +21,13 @@ export default defineConfig(({ command }) => ({
     },
   },
   base: '/ptc/',
+  server: {
+    proxy: {
+      '/api': {
+        target: 'http://t.ptcrepair.com.au/care',
+        changeOrigin: true,
+        rewrite: path => path.replace(/^\/api/, ''),
+      },
+    },
+  },
 }))