dsh-qwenwork-connect 0.2.0 → 0.2.1
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.
- package/lib/loopback.js +14 -3
- package/package.json +1 -1
package/lib/loopback.js
CHANGED
|
@@ -14,10 +14,21 @@
|
|
|
14
14
|
* 那时 Host 不是环回但请求仍来自本机代理;部署时用这个环境变量补齐。
|
|
15
15
|
*/
|
|
16
16
|
function extraTrustedHosts() {
|
|
17
|
-
const
|
|
17
|
+
const parts = [];
|
|
18
|
+
const fromEnv = process.env.QWENWORK_TRUSTED_HOSTS;
|
|
19
|
+
if (typeof fromEnv === 'string' && fromEnv.length > 0) parts.push(fromEnv);
|
|
20
|
+
// DSH 往往由 systemd 托管,进程环境改不了;用文件更实际:
|
|
21
|
+
// ~/.dsh/qwenwork-trusted-hosts,一行一个域名(也接受逗号分隔)。
|
|
22
|
+
try {
|
|
23
|
+
const file = path.join(os.homedir(), '.dsh', 'qwenwork-trusted-hosts');
|
|
24
|
+
parts.push(fs.readFileSync(file, 'utf8'));
|
|
25
|
+
} catch {
|
|
26
|
+
// 没有这个文件就是不需要额外放行
|
|
27
|
+
}
|
|
18
28
|
return new Set(
|
|
19
|
-
|
|
20
|
-
.
|
|
29
|
+
parts
|
|
30
|
+
.join(',')
|
|
31
|
+
.split(/[s,]+/)
|
|
21
32
|
.map((item) => item.trim().toLowerCase())
|
|
22
33
|
.filter((item) => item.length > 0),
|
|
23
34
|
);
|