@myassis/gateway 1.0.94 → 1.0.95

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -40,20 +40,20 @@ function getPackageRootDir() {
40
40
  return path.resolve(__dirname, '..', '..');
41
41
  }
42
42
  const getEnvPath = () => {
43
- // 1. 用户工作目录(运行时配置优先)
44
- const cwdEnvPath = path.resolve(process.cwd(), '.env');
45
- if (fs.existsSync(cwdEnvPath)) {
46
- return cwdEnvPath;
47
- }
48
- // 2. pkg 环境:从 snapshot 虚拟路径读取打包的 .env
43
+ // 1. pkg 打包环境:优先从 snapshot 读取随包发布的 .env(生产默认值)。
44
+ // 不能让 cwd/.env 优先——pkg exe 放在源码目录旁运行时,cwd 下的
45
+ // 开发 .env(指向局域网地址)会覆盖生产默认值,导致登录 500。
49
46
  if (process.pkg) {
50
- // __dirname 在 pkg 中指向 /snapshot/myassis/gateway/dist/config
51
- // 打包的 .env 在 /snapshot/myassis/gateway/dist/.env
52
47
  const snapshotEnvPath = path.resolve(__dirname, '..', '.env');
53
48
  if (fs.existsSync(snapshotEnvPath)) {
54
49
  return snapshotEnvPath;
55
50
  }
56
51
  }
52
+ // 2. 非打包(开发)环境:工作目录 .env 优先
53
+ const cwdEnvPath = path.resolve(process.cwd(), '.env');
54
+ if (fs.existsSync(cwdEnvPath)) {
55
+ return cwdEnvPath;
56
+ }
57
57
  // 3. 包安装目录(随包发布的默认 .env)
58
58
  const pkgEnvPath = path.join(getPackageRootDir(), 'dist', '.env');
59
59
  if (fs.existsSync(pkgEnvPath)) {
@@ -0,0 +1 @@
1
+ ok
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myassis/gateway",
3
- "version": "1.0.94",
3
+ "version": "1.0.95",
4
4
  "description": "我的助手 Gateway Service - 本地 AI 网关服务,支持认证、WebSocket 实时通信和任务调度",
5
5
  "main": "dist/index.js",
6
6
  "bin": {