Skip to content

fix(webui): inline NODE_ENV in main process build to ensure correct default port#1748

Merged
piorpua merged 4 commits intoiOfficeAI:mainfrom
Jassy930:fix/webui-default-port-node-env
Mar 29, 2026
Merged

fix(webui): inline NODE_ENV in main process build to ensure correct default port#1748
piorpua merged 4 commits intoiOfficeAI:mainfrom
Jassy930:fix/webui-default-port-node-env

Conversation

@Jassy930
Copy link
Copy Markdown
Contributor

Summary

  • Packaged AionUi (e.g. brew install) uses dev port 25809 instead of production port 25808 because process.env.NODE_ENV is not statically replaced during the main process build

Changes

  • Add 'process.env.NODE_ENV': JSON.stringify(mode) to the main process define block in electron.vite.config.ts
  • This ensures NODE_ENV is inlined at build time, so WEBUI_DEFAULT_PORT resolves to 25808 in production builds

Related Issue

Closes #1747

Test Plan

  • Run electron-vite build and verify the output bundle contains the literal string "production" instead of process.env.NODE_ENV
  • Launch the packaged app and confirm WebUI starts on port 25808
  • Run electron-vite dev and confirm dev mode still uses port 25809

…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.
@sentry
Copy link
Copy Markdown

sentry bot commented Mar 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@piorpua piorpua added the bot:reviewing Review in progress (mutex) label Mar 27, 2026
@piorpua piorpua added bot:reviewing Review in progress (mutex) and removed bot:reviewing Review in progress (mutex) labels Mar 27, 2026
@piorpua
Copy link
Copy Markdown
Contributor

piorpua commented Mar 28, 2026

Code Review:fix(webui): inline NODE_ENV in main process build to ensure correct default port (#1748)

变更概述

本 PR 在 electron.vite.config.ts 的主进程 define 块中新增 'process.env.NODE_ENV': JSON.stringify(mode),确保构建时将 NODE_ENV 静态内联,修复打包版本(如 brew install)错误使用开发端口 25809 而非生产端口 25808 的问题。


方案评估

结论:✅ 方案合理

electron-vite 在主进程(Node.js 环境)构建时不会自动替换 process.env.NODE_ENV,不同于渲染进程由 Vite 自动处理。通过 define 显式内联 mode 是标准做法,与同一 define 块中其他变量(process.env.envprocess.env.SENTRY_DSN)风格一致。方案改动最小,精准修复目标问题,无副作用。


问题清单

✅ 未发现明显问题,代码质量良好,建议批准合并。


汇总

无问题。

结论

批准合并 — 单行精准修复,方案正确,无阻塞性问题。


本报告由本地 pr-review skill 生成,包含完整项目上下文,无截断限制。

@piorpua piorpua added bot:reviewing Review in progress (mutex) and removed bot:reviewing Review in progress (mutex) labels Mar 28, 2026
@piorpua piorpua added bot:reviewing Review in progress (mutex) and removed bot:reviewing Review in progress (mutex) labels Mar 28, 2026
@piorpua piorpua merged commit 871a673 into iOfficeAI:main Mar 29, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(webui): packaged app uses dev port 25809 instead of production port 25808

2 participants