Skip to content

Environment and Build ​

Vite merges .env with the active mode file. build/utils.ts then converts feature flags to booleans.

Variables ​

VariableDefaultDescription
VITE_API_BASE_URL/apiAxios base URL and development proxy prefix
VITE_AI_API_BASE_URL/api/aiStreaming AI API prefix
VITE_API_TARGETemptyReal backend target for local development
VITE_AI_API_TARGETemptyLocal FastAPI AI service target
VITE_USE_MOCKfalseEnable Vite Mock; development sets it to true
VITE_USE_ERUDAfalseEnable the mobile debug console
VITE_USE_COMPRESSfalseGenerate Gzip assets
VITE_USE_REPORTfalseGenerate a bundle analysis report
VITE_USE_HTTPSfalseEnable local HTTPS
VITE_PWA_ENABLEDfalseEnable PWA support
VITE_IMAGE_OPTIMIZEfalseOptimize images in production builds only
VITE_UI_FRAMEWORKvantSelect Vant, NutUI, or Varlet at build time

Mock Mode ​

.env.development enables Mock by default. Login uses /api/auth/login; the catalog and administration use /api/products and /api/admin/products. mock/index.ts implements the same contracts.

Use a Real Backend ​

ini
VITE_API_BASE_URL=/api
VITE_AI_API_BASE_URL=/api/ai
VITE_API_TARGET=http://localhost:8002
VITE_AI_API_TARGET=http://localhost:8001
VITE_USE_MOCK=false

The dev server routes /api/ai to FastAPI first, then sends the remaining /api traffic to Gin. Paths are preserved; production gateways should use the same routing rule.

Production ​

bash
pnpm build

Mock and Eruda are disabled in production. Keep a same-origin /api behind a gateway, or override VITE_API_BASE_URL in the deployment environment.

Released under the MIT License