Add refresh button to Docker widget with server cache bust
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
2026-05-16 18:11:49 +02:00
parent fc0ad6e68e
commit be16444e93
2 changed files with 37 additions and 12 deletions
+7 -3
View File
@@ -123,15 +123,19 @@ async function getLscrLatestDigest(image: string, tag: string): Promise<string |
return getGenericRegistryDigest('lscr.io', image, tag, process.env.GITHUB_TOKEN)
}
router.get('/docker', async (_req, res) => {
router.get('/docker', async (req, res) => {
const host = process.env.PORTAINER_HOST
if (!host) {
res.status(503).json({ error: 'PORTAINER_HOST not configured' })
return
}
const cached = fromCache<{ containers: ContainerInfo[] }>('docker:full', HUB_TTL)
if (cached) { res.json(cached); return }
if (!req.query.refresh) {
const cached = fromCache<{ containers: ContainerInfo[] }>('docker:full', HUB_TTL)
if (cached) { res.json(cached); return }
} else {
delete cache['docker:full']
}
try {
const headers = portainerHeaders()