keep overview: print which server it's talking to
All checks were successful
Docker / build-and-push (push) Successful in 1m53s

Surfaced by a real mix-up this session: KEEP_SERVER_URL was set to a
"dev"-named hostname, and it was unclear without checking DNS/proxy
config whether that was actually the same server as the one running
on the deploy VPS or a separate instance -- nothing in `overview`'s
output (vault names, recipient labels) says which server answered.
Defaults silently to localhost:3050 if the env var isn't set at all,
which is its own way to end up looking at the wrong thing.

Printed before the fetch, not after, so it still shows up on a failed
request ("error: fetch failed") -- the exact case where knowing the
target mattered most and, before this, showed nothing at all.

Verified against a local test server: shows the right URL on success,
and shows the (default, unset) URL immediately before a deliberately
failed fetch to a port nothing's listening on.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Fredrik Johansson
2026-07-15 16:25:40 +02:00
parent 74122b25cd
commit bb7f890a68

View File

@@ -1,4 +1,4 @@
import { adminFetch, expectOk } from '../signedFetch.js';
import { adminFetch, expectOk, serverUrl } from '../signedFetch.js';
export async function recipientAdd(label: string, publicKey: string): Promise<void> {
const data = await expectOk(await adminFetch('POST', '/api/admin/recipients', { label, publicKey }));
@@ -20,9 +20,18 @@ export async function recipientRemove(recipientId: string): Promise<void> {
}
export async function adminOverview(): Promise<void> {
// Printed before the fetch, not after -- which server this hit is exactly
// the thing that's ambiguous from the rest of the output alone (no vault
// or recipient here says "production" or "dev"), and defaults silently
// to localhost:3050 if KEEP_SERVER_URL isn't set. Printing it first means
// it still shows up even when the fetch itself fails ("error: fetch
// failed") -- the exact case where knowing the target mattered most and
// previously showed nothing at all.
console.log(`server: ${serverUrl()}`);
const data = await expectOk(await adminFetch('GET', '/api/admin/overview'));
console.log('recipients:');
console.log('\nrecipients:');
if (!data.recipients.length) console.log(' none yet.');
for (const r of data.recipients) {
console.log(` ${r.recipientId} ${r.label}`);