From 90b12935a439eb5b2679c2d498bae4510b70f62e Mon Sep 17 00:00:00 2001 From: Admin Date: Fri, 17 Jul 2026 07:28:17 +0000 Subject: [PATCH] fix: ensure JWT secret always has a value --- internal/config/config.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/config/config.go b/internal/config/config.go index 7eaf1f3..6337095 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -89,7 +89,12 @@ func Load(configPath string) error { return err } - // 从环境变量读取 JWT Secret + // 确保 JWT Secret 有值 + if Cfg.JWT.Secret == "" { + Cfg.JWT.Secret = "default-jwt-secret-change-in-production" + } + + // 从环境变量读取 JWT Secret(优先级更高) if secret := os.Getenv("JWT_SECRET"); secret != "" { Cfg.JWT.Secret = secret }