chore: document env files and configure proxy target
Add VITE_PROXY_TARGET to the example environment file and use it in the Vite dev proxy configuration with a localhost fallback. Expand the LLM development guide with env file loading order, version-control rules, and variable descriptions. Also clean up ignored local tool paths in .gitignore and remove duplicated README env examples.chore: document env files and configure proxy target Add VITE_PROXY_TARGET to the example environment file and use it in the Vite dev proxy configuration with a localhost fallback. Expand the LLM development guide with env file loading order, version-control rules, and variable descriptions. Also clean up ignored local tool paths in .gitignore and remove duplicated README env examples.
This commit is contained in:
@@ -1,3 +1,6 @@
|
|||||||
|
# Vite dev proxy 目標後端 URL。
|
||||||
|
VITE_PROXY_TARGET=http://192.168.89.54:9002
|
||||||
|
|
||||||
# Vite API base URL。
|
# Vite API base URL。
|
||||||
# 使用 Vite dev proxy 時,建議維持相對路徑。
|
# 使用 Vite dev proxy 時,建議維持相對路徑。
|
||||||
VITE_API_BASE_URL=/service/api
|
VITE_API_BASE_URL=/service/api
|
||||||
|
|||||||
+7
-9
@@ -36,13 +36,11 @@ output/playwright/
|
|||||||
/blob-report/
|
/blob-report/
|
||||||
/playwright/.cache/
|
/playwright/.cache/
|
||||||
/playwright/.auth/
|
/playwright/.auth/
|
||||||
# Added by code-review-graph
|
|
||||||
.code-review-graph/
|
|
||||||
|
|
||||||
.codex/config.toml
|
.codex
|
||||||
.agents/
|
.agents
|
||||||
.claude/
|
.claude
|
||||||
.ruler/
|
.ruler
|
||||||
.playwright/
|
.playwright
|
||||||
.mcp.json
|
opencode.json
|
||||||
.opencode.json
|
.antigravitycli
|
||||||
|
|||||||
@@ -67,15 +67,6 @@ pnpm dev
|
|||||||
cp .env.example .env
|
cp .env.example .env
|
||||||
```
|
```
|
||||||
|
|
||||||
常用設定:
|
|
||||||
|
|
||||||
```env
|
|
||||||
VITE_API_BASE_URL=/service/api
|
|
||||||
VITE_SKIP_LOGIN=false
|
|
||||||
VITE_DEV_DEFAULT_USER_ID=
|
|
||||||
VITE_DEV_DEFAULT_PASSWORD=
|
|
||||||
```
|
|
||||||
|
|
||||||
`client.ts` 會優先使用 `VITE_API_BASE_URL`,否則預設 `/service/api`。開發模式下,Vite proxy 會將 `/service/*` 轉送到後端。
|
`client.ts` 會優先使用 `VITE_API_BASE_URL`,否則預設 `/service/api`。開發模式下,Vite proxy 會將 `/service/*` 轉送到後端。
|
||||||
|
|
||||||
實際 `.env` 與 `.env.*.local` 不應提交。production API URL 應由使用專案自己的部署環境提供。
|
實際 `.env` 與 `.env.*.local` 不應提交。production API URL 應由使用專案自己的部署環境提供。
|
||||||
|
|||||||
@@ -64,6 +64,43 @@
|
|||||||
- 錯誤頁:讀 `src/views/GUIDE.md`(ErrorShell 模式)與 `src/router/GUIDE.md`(錯誤頁路由慣例)。
|
- 錯誤頁:讀 `src/views/GUIDE.md`(ErrorShell 模式)與 `src/router/GUIDE.md`(錯誤頁路由慣例)。
|
||||||
- 語系文案:讀 `src/language/GUIDE.md`。
|
- 語系文案:讀 `src/language/GUIDE.md`。
|
||||||
|
|
||||||
|
## 環境變數(.env 檔案)
|
||||||
|
|
||||||
|
Vite 會依 mode 自動載入對應層級的 `.env` 檔案,優先順序由高到低:
|
||||||
|
|
||||||
|
```
|
||||||
|
.env.[mode].local ← 本機覆蓋,不提交(最高優先)
|
||||||
|
.env.[mode] ← mode 專用
|
||||||
|
.env.local ← 本機覆蓋,不提交
|
||||||
|
.env ← 所有 mode 通用
|
||||||
|
```
|
||||||
|
|
||||||
|
專案實際使用與版本控制規則:
|
||||||
|
|
||||||
|
| 檔案 | 用途 | Git |
|
||||||
|
|------|------|-----|
|
||||||
|
| `.env.example` | 範本檔,列出所有可用變數與說明 | 提交 |
|
||||||
|
| `.env` | 所有 Vite 指令皆載入(serve / build) | 忽略 |
|
||||||
|
| `.env.development` | `vite serve`(mode=development)載入 | 忽略 |
|
||||||
|
| `.env.development.local` | 本機開發機密值(帳號密碼等) | 忽略 |
|
||||||
|
| `.env.production` | `vite build`(mode=production)載入 | 忽略 |
|
||||||
|
|
||||||
|
**新增環境變數時應遵守的順序:**
|
||||||
|
|
||||||
|
1. 在 `.env` 或 `.env.development` 中新增變數並給定預設值
|
||||||
|
2. 在 `.env.example` 中加入該變數的說明與格式,供其他開發者參考
|
||||||
|
3. 若變數包含機密資訊(帳號、密碼、token),僅放在 `.env.development.local`,不要寫入 `.env.example` 的預設值
|
||||||
|
|
||||||
|
**現有變數說明:**
|
||||||
|
|
||||||
|
| 變數 | 適用檔案 | 說明 |
|
||||||
|
|------|----------|------|
|
||||||
|
| `VITE_PROXY_TARGET` | `.env`, `.env.development`, `.env.development.local` | dev server proxy 目標後端 URL |
|
||||||
|
| `VITE_API_BASE_URL` | `.env`, `.env.development`, `.env.production` | API 請求 base URL,dev 用相對路徑走 proxy,prod 用完整 URL |
|
||||||
|
| `VITE_SKIP_LOGIN` | `.env.development` | 登入示範開關,`true` 時略過登入流程 |
|
||||||
|
| `VITE_DEV_DEFAULT_USER_ID` | `.env.development.local` | 本機開發示範帳號 |
|
||||||
|
| `VITE_DEV_DEFAULT_PASSWORD` | `.env.development.local` | 本機開發示範密碼 |
|
||||||
|
|
||||||
## 修改前檢查
|
## 修改前檢查
|
||||||
|
|
||||||
- 是否碰到 template core。
|
- 是否碰到 template core。
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
{
|
|
||||||
"$schema": "https://opencode.ai/config.json",
|
|
||||||
"mcp": {
|
|
||||||
"vuetify-mcp": {
|
|
||||||
"type": "remote",
|
|
||||||
"url": "https://mcp.vuetifyjs.com/mcp",
|
|
||||||
"enabled": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+1
-1
@@ -36,7 +36,7 @@ export default defineConfig({
|
|||||||
port: 3700,
|
port: 3700,
|
||||||
proxy:{
|
proxy:{
|
||||||
"/service/": {
|
"/service/": {
|
||||||
target: "http://192.168.89.54:9002",
|
target: process.env.VITE_PROXY_TARGET || "http://localhost:8080",
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user