Files
web/CONFIG.md
2026-03-17 01:00:11 +08:00

51 lines
1.6 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 配置文件位置与加载方式
**对外域名:** https://yuheng.yuxindazhineng.com官网 /admin 管理后台 /api 接口均同域,由 Nginx Proxy Manager 反向代理)
---
## 一、后端API 服务)— 启动时自动读取
**配置文件:****server/.env** 一个文件。需要改配置时直接编辑该文件即可。
-`server` 目录下启动时,加载 `server/.env`
- 在项目根目录启动时,加载 `server/.env`
**变量说明:**`server/.env.example`(仅作参考,可不保留)。
---
## 二、前台(官网)— 构建时注入
**配置文件位置:**
| 环境 | 路径 | 说明 |
|------|------|------|
| 生产 | **web/.env.production** | 执行 `npm run build` 时注入 |
| 示例 | web/.env.example | 复制为 .env 或 .env.production 后修改 |
变量需以 `VITE_` 开头才会被打包进前端,如:`VITE_APP_DOMAIN``VITE_API_BASE`
---
## 三、后台(管理端)— 构建时注入
**配置文件位置:**
| 环境 | 路径 | 说明 |
|------|------|------|
| 生产 | **admin/.env.production** | 执行 `npm run build` 时注入 |
| 示例 | admin/.env.example | 复制为 .env 或 .env.production 后修改 |
变量需以 `VITE_` 开头,如:`VITE_APP_DOMAIN``VITE_API_BASE`
---
## 四、汇总表
| 端 | 配置文件 | 自动读取时机 |
|----|----------|--------------|
| 后端 | **server/.env** | **进程启动时**自动加载 |
| 前台 | **web/**.env.production | 执行 `npm run build` 时注入 |
| 后台 | **admin/**.env.production | 执行 `npm run build` 时注入 |