ework-web 0.10.1 → 0.10.2
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/package.json +1 -1
- package/src/daemon-deploy.ts +5 -1
- package/src/index.ts +3 -0
- package/src/static/daemon-mgr.js +4 -0
package/package.json
CHANGED
package/src/daemon-deploy.ts
CHANGED
|
@@ -99,9 +99,13 @@ function buildSetupScript(envBlock: string, daemonPort: number): string {
|
|
|
99
99
|
`npm install -g ework-aio`,
|
|
100
100
|
`echo "[2/4] writing daemon config..."`,
|
|
101
101
|
`mkdir -p ~/.local/share/ework-aio/ework-daemon`,
|
|
102
|
-
`
|
|
102
|
+
`REMOTE_IP=$(hostname -I 2>/dev/null | awk '{print $1}')`,
|
|
103
|
+
`DAEMON_ENDPOINT_LINE=""`,
|
|
104
|
+
`if [ -n "$REMOTE_IP" ]; then DAEMON_ENDPOINT_LINE="DAEMON_ENDPOINT=$REMOTE_IP:${String(daemonPort)}"; fi`,
|
|
105
|
+
`{ cat <<'EWORK_DAEMON_ENV_EOF'`,
|
|
103
106
|
envBlock,
|
|
104
107
|
`EWORK_DAEMON_ENV_EOF`,
|
|
108
|
+
`echo "$DAEMON_ENDPOINT_LINE"; } > ~/.local/share/ework-aio/ework-daemon/.env`,
|
|
105
109
|
`echo "[3/4] starting daemon..."`,
|
|
106
110
|
`ework-aio start daemon`,
|
|
107
111
|
`echo "[4/4] verifying daemon is alive..."`,
|
package/src/index.ts
CHANGED
|
@@ -479,6 +479,9 @@ async function handle(req: Request, url: URL, ip: string, ctx: { authed: boolean
|
|
|
479
479
|
|
|
480
480
|
const auth = await checkAuth(req, cfg, ip);
|
|
481
481
|
if (!auth.ok) {
|
|
482
|
+
if (url.pathname.startsWith("/api/")) {
|
|
483
|
+
return json({ error: "authentication required" }, 401);
|
|
484
|
+
}
|
|
482
485
|
const next = sanitizeNext(url.pathname + url.search);
|
|
483
486
|
return Response.redirect(`${url.origin}/login?next=${encodeURIComponent(next)}`, 302);
|
|
484
487
|
}
|
package/src/static/daemon-mgr.js
CHANGED
|
@@ -159,6 +159,10 @@
|
|
|
159
159
|
setResult('正在重启 daemon #' + id + '…', 'loading');
|
|
160
160
|
try {
|
|
161
161
|
var res = await fetch('/api/daemons/' + id + '/restart', { method: 'POST' });
|
|
162
|
+
if (res.status === 401) {
|
|
163
|
+
setResult('✗ 登录已过期,请刷新页面重新登录', 'err');
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
162
166
|
var data = await res.json();
|
|
163
167
|
if (data.ok) {
|
|
164
168
|
setResult('✓ daemon #' + id + ' 已重新激活', 'ok');
|