Skip to content

fix: improve env variable loading and normalize boolean strings#133

Open
sjnhnp wants to merge 3 commits intomiantiao-me:mainfrom
sjnhnp:main
Open

fix: improve env variable loading and normalize boolean strings#133
sjnhnp wants to merge 3 commits intomiantiao-me:mainfrom
sjnhnp:main

Conversation

@sjnhnp
Copy link

@sjnhnp sjnhnp commented Jan 28, 2026

问题描述:

1、环境变量读取限制:在某些部署环境(如 Node.js 模式或特定 CI/CD)下,由于 Vite 对 import.meta.env 的静态替换机制,使用动态 Key 访问环境变量可能会失败。

2、布尔值识别问题:来自 Cloudflare Pages 或其他平台的配置常以字符串形式(如 "true"/"false")传入,直接在逻辑中使用或仅比对字符串容易导致判断失效。

修改内容:

1、增强 getEnv函数:增加了对 process.env 的降级支持,确保在 SSR 或 Node ��行时下能更可靠地读取配置。
2、布尔值规范化:在 getEnv中自动将 "true" 和 "false" 字符串转换为对应的布尔值。

影响: 提高了配置系统的健壮性,使得 HIDE_DESCRIPTION、REACTIONS 等布尔类型的配置在各平台下表现更一致。

#125

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant