From 24df541392ef18e0b8805c5cbeb5672aec6d1ea6 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Fri, 30 Jun 2023 17:09:47 +0800 Subject: [PATCH] add env --- .env.development | 1 + .env.production | 1 + src/api/index.ts | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 .env.development create mode 100644 .env.production diff --git a/.env.development b/.env.development new file mode 100644 index 00000000..b27eade5 --- /dev/null +++ b/.env.development @@ -0,0 +1 @@ +VITE_API_BASE_URL=http://localhost:3001/api/v1/ diff --git a/.env.production b/.env.production new file mode 100644 index 00000000..7fcf8e0c --- /dev/null +++ b/.env.production @@ -0,0 +1 @@ +VITE_API_BASE_URL=/api/v1/ diff --git a/src/api/index.ts b/src/api/index.ts index 2dab65cf..6da16f46 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -4,7 +4,7 @@ import axios from 'axios' // 创建axios实例 const api = axios.create({ - baseURL: '/api/v1/', + baseURL: import.meta.env.VITE_API_BASE_URL, }) // 添加请求拦截器