fix: improve env variable loading and normalize boolean strings#133
Open
sjnhnp wants to merge 3 commits intomiantiao-me:mainfrom
Open
fix: improve env variable loading and normalize boolean strings#133sjnhnp wants to merge 3 commits intomiantiao-me:mainfrom
sjnhnp wants to merge 3 commits intomiantiao-me:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题描述:
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