From 1b34db1109f9d7016a3a405ac5943144c05cb410 Mon Sep 17 00:00:00 2001 From: Ciy <903736662@qq.com> Date: Sun, 30 Apr 2023 14:45:27 +0800 Subject: [PATCH] solving docker multiple names --- src/pages/api/docker/stats/[...service].js | 2 +- src/pages/api/docker/status/[...service].js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/api/docker/stats/[...service].js b/src/pages/api/docker/stats/[...service].js index e27cd35c4..8f8d2dc1c 100644 --- a/src/pages/api/docker/stats/[...service].js +++ b/src/pages/api/docker/stats/[...service].js @@ -30,7 +30,7 @@ export default async function handler(req, res) { }); } - const containerNames = containers.map((container) => container.Names[0]?.replace(/^\//, "")); + const containerNames = containers.flatMap((container) => container.Names.map((name) => name.replace(/^\//, ""))); const containerExists = containerNames.includes(containerName); if (containerExists) { diff --git a/src/pages/api/docker/status/[...service].js b/src/pages/api/docker/status/[...service].js index bb03a6379..eed566de8 100644 --- a/src/pages/api/docker/status/[...service].js +++ b/src/pages/api/docker/status/[...service].js @@ -30,7 +30,7 @@ export default async function handler(req, res) { }); } - const containerNames = containers.map((container) => container.Names[0]?.replace(/^\//, "")); + const containerNames = containers.flatMap((container) => container.Names.map((name) => name.replace(/^\//, ""))); const containerExists = containerNames.includes(containerName); if (containerExists) {