diff --git a/src/routes/admin.ts b/src/routes/admin.ts index aad2653..cfc1f8c 100644 --- a/src/routes/admin.ts +++ b/src/routes/admin.ts @@ -28,8 +28,17 @@ adminRoutes.get('/admin/tailscale/routes', async (c) => { }) adminRoutes.get('/admin/tailscale/acl', async (c) => { - return c.json({ - policy: await headscaleAdapter.getPolicyStatus(), - fetchedAt: new Date().toISOString(), - }) + const emptyPolicy = { groups: {}, tagOwners: {}, acls: [], raw: null } + try { + return c.json({ + policy: await headscaleAdapter.getPolicyStatus(), + fetchedAt: new Date().toISOString(), + }) + } catch (error) { + return c.json({ + policy: emptyPolicy, + error: error instanceof Error ? error.message : String(error), + fetchedAt: new Date().toISOString(), + }) + } })