diff --git a/.env b/.env index a0be673..28c1b49 100644 --- a/.env +++ b/.env @@ -1 +1 @@ -# VITE_BASE_API_URL=http://localhost:5173 \ No newline at end of file +API_BASE_URL=http://192.168.1.36:9527/api \ No newline at end of file diff --git a/package.json b/package.json index 145db54..04559ce 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "@vue/eslint-config-typescript": "^14.6.0", "@vue/test-utils": "^2.4.6", "cypress": "^15.7.1", + "dotenv": "^17.2.3", "eslint": "^9.39.1", "eslint-plugin-format": "^1.1.0", "eslint-plugin-vue": "^10.6.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 349e8d0..7d0b73e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -75,6 +75,9 @@ importers: cypress: specifier: ^15.7.1 version: 15.7.1 + dotenv: + specifier: ^17.2.3 + version: 17.2.3 eslint: specifier: ^9.39.1 version: 9.39.1 @@ -2061,6 +2064,10 @@ packages: resolution: {integrity: sha512-k1gCAXAsNgLwEL+Y8Wvl+M6oEFj5bgazfZULpS5CneoPPXRaCCW7dm+q21Ky2VEE5X+VeRDBVg1Pcvvsr4TtNQ==} engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0} + dotenv@17.2.3: + resolution: {integrity: sha512-JVUnt+DUIzu87TABbhPmNfVdBDt18BLOWjMUFJMSi/Qqg7NTYtabbvSNJGOJ7afbRuv9D/lngizHtP7QyLQ+9w==} + engines: {node: '>=12'} + dunder-proto@1.0.1: resolution: {integrity: sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==} engines: {node: '>= 0.4'} @@ -6241,6 +6248,8 @@ snapshots: diff-sequences@27.5.1: {} + dotenv@17.2.3: {} + dunder-proto@1.0.1: dependencies: call-bind-apply-helpers: 1.0.2 diff --git a/vite.config.ts b/vite.config.ts index e3056e4..792e078 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -2,11 +2,16 @@ import path from "node:path"; import legacy from "@vitejs/plugin-legacy"; import vue from "@vitejs/plugin-vue"; import jsx from "@vitejs/plugin-vue-jsx"; +import dotenv from "dotenv"; import autoImport from "unplugin-auto-import/vite"; import { IonicResolver } from "unplugin-vue-components/resolvers"; import components from "unplugin-vue-components/vite"; import { defineConfig } from "vite"; +const env = dotenv.config({ path: `.env` }).parsed as Record; + +console.log("🚀 ~ file: vite.config.ts:7 ~ env:", env); + // https://vitejs.dev/config/ export default defineConfig({ plugins: [ @@ -32,7 +37,7 @@ export default defineConfig({ host: true, proxy: { "/api": { - target: "http://192.168.1.36:9527/api", + target: env.API_BASE_URL, changeOrigin: true, }, },