fix(webui): inline NODE_ENV in main process build to ensure correct default port#1748
Merged
piorpua merged 4 commits intoiOfficeAI:mainfrom Mar 29, 2026
Merged
Conversation
…efault port electron-vite does not automatically replace process.env.NODE_ENV in the main process bundle. This causes the packaged Electron app (e.g. brew-installed) to evaluate NODE_ENV as undefined at runtime, falling back to the development port 25809 instead of the production port 25808. Add process.env.NODE_ENV to the main process define config so it gets statically replaced at build time with the correct mode value.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
Code Review:fix(webui): inline NODE_ENV in main process build to ensure correct default port (#1748)变更概述本 PR 在 方案评估结论:✅ 方案合理 electron-vite 在主进程(Node.js 环境)构建时不会自动替换 问题清单✅ 未发现明显问题,代码质量良好,建议批准合并。 汇总无问题。 结论✅ 批准合并 — 单行精准修复,方案正确,无阻塞性问题。 本报告由本地 |
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.
Summary
process.env.NODE_ENVis not statically replaced during the main process buildChanges
'process.env.NODE_ENV': JSON.stringify(mode)to the main processdefineblock inelectron.vite.config.tsNODE_ENVis inlined at build time, soWEBUI_DEFAULT_PORTresolves to 25808 in production buildsRelated Issue
Closes #1747
Test Plan
electron-vite buildand verify the output bundle contains the literal string"production"instead ofprocess.env.NODE_ENVelectron-vite devand confirm dev mode still uses port 25809