Files
backend_v2/configs/config.yml
toom1996 30c9f21da4 update
2026-08-26 10:45:21 +08:00

64 lines
2.4 KiB
YAML
Raw 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.

# ============================================================
# Fashion API 配置文件(唯一配置源)
#
# 加载优先级:环境变量 > 本文件 > 代码内置默认值
# - 本地开发:直接改本文件即可,无需任何环境变量
# - 容器部署:保持本文件为默认值,用环境变量覆盖敏感项(见每项 env 注释)
#
# 配置文件路径可通过 -config 启动参数或 CONFIG_PATH 环境变量指定,
# 默认按 ./configs/config.yml → ./config.yml 顺序查找。
# ============================================================
server:
# 监听端口。前端 test 项目的 PUBLIC_API_BASE 指向 http://localhost:8090,
# 且 src/lib/api.ts 在 DEV 模式下硬编码回落到 8090,因此默认必须是 8090。
port: 8090 # env: SERVER_PORT
# gin 运行模式:debug(开发,输出彩色路由日志)| release(生产)| test
mode: debug # env: GIN_MODE
# 优雅关闭的最长等待时间(秒)
shutdown_timeout: 10
database:
host: 127.0.0.1 # env: DB_HOST
port: 3306 # env: DB_PORT
user: root # env: DB_USER
password: root # env: DB_PASSWORD(兼容 DB_PASS)
# 本地开发库名为 db;docker-compose 部署时用环境变量覆盖为 fashionadmin
name: db # env: DB_NAME
charset: utf8mb4
# GORM 日志级别:silent | error | warn | info
log_level: warn
# 连接池
max_idle_conns: 10
max_open_conns: 100
conn_max_lifetime: 3600 # 秒
jwt:
# 生产环境务必用环境变量覆盖为随机长字符串
secret: dev-secret-change-me-fashion-2026 # env: JWT_SECRET
# token 有效期(小时),168 = 7 天,与原项目一致
expire_hours: 168
upload:
# 图片存储目录。接口返回的封面/图片为相对路径(如 /uploads/xxx.jpg),
# 前端通过 toAbs() 拼接为绝对地址,因此必须对外提供静态文件服务。
dir: ./uploads # env: UPLOAD_DIR
# 静态文件访问前缀,需与数据库中存储的图片路径前缀一致
url_prefix: /uploads
cors:
# 允许的来源,"*" 表示全部(与原项目行为一致)
allow_origins:
- "*"
allow_methods:
- GET
- POST
- PUT
- DELETE
- OPTIONS
allow_headers:
- Content-Type
- Authorization
- X-Requested-With
max_age: 86400 # 预检请求缓存秒数