fix(auth): OnModuleInit改为warn而非throw,避免生产缺APPLE_BUNDLE_ID时进程崩溃
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 45s

This commit is contained in:
wangdl 2026-05-27 20:24:23 +08:00
parent 5fcfc87f84
commit c6fd1731d5

View File

@ -27,12 +27,14 @@ export class AppleAuthService implements OnModuleInit {
const nodeEnv = process.env.NODE_ENV; const nodeEnv = process.env.NODE_ENV;
if (nodeEnv === 'production') { if (nodeEnv === 'production') {
if (!this.appleBundleId) { if (!this.appleBundleId) {
throw new Error( this.logger.error(
'生产环境必须设置 APPLE_BUNDLE_ID 环境变量。\n' + '生产环境未配置 APPLE_BUNDLE_IDApple 登录将返回 401。\n' +
'请在 .env 中添加: APPLE_BUNDLE_ID=com.your.bundle.id', '请在 .env 中添加: APPLE_BUNDLE_ID=com.your.bundle.id',
); );
// 不抛异常 — 拒绝启动会阻断整个服务。运行时已保证 401 拒绝。
} else {
this.logger.log('Apple 登录已配置,使用真实验签');
} }
this.logger.log('Apple 登录已配置,使用真实验签');
} else { } else {
if (this.appleBundleId) { if (this.appleBundleId) {
this.logger.log('Apple 登录使用真实验签模式(已配置 bundleId'); this.logger.log('Apple 登录使用真实验签模式(已配置 bundleId');