From af55992627ef2fe1f32de59c963cf0f5dcbad7ad Mon Sep 17 00:00:00 2001 From: Wang Zhuoxuan Date: Sat, 18 Apr 2026 03:27:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20health=20check=20=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E8=A1=A5=E5=85=85=20/v1=20=E5=89=8D=E7=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit API 路由挂载在 /v1 下,/health 路径被 auth 中间件拦截返回 401, 统一改为 /v1/health。 --- .gitea/workflows/deploy.yml | 4 ++-- Dockerfile | 2 +- docker-compose.prod.yml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 36f07e4..fdac6f8 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -69,7 +69,7 @@ jobs: run: | sleep 10 for i in {1..5}; do - if bun -e "fetch('http://localhost:3001/health').then(r=>r.ok?process.exit(0):process.exit(1)).catch(()=>process.exit(1))"; then + if bun -e "fetch('http://localhost:3001/v1/health').then(r=>r.ok?process.exit(0):process.exit(1)).catch(()=>process.exit(1))"; then echo "Test environment is healthy!" exit 0 fi @@ -107,7 +107,7 @@ jobs: run: | sleep 15 for i in {1..5}; do - if bun -e "fetch('http://localhost:3000/health').then(r=>r.ok?process.exit(0):process.exit(1)).catch(()=>process.exit(1))"; then + if bun -e "fetch('http://localhost:3000/v1/health').then(r=>r.ok?process.exit(0):process.exit(1)).catch(()=>process.exit(1))"; then echo "Production deployment successful!" exit 0 fi diff --git a/Dockerfile b/Dockerfile index 1aeebdd..8ebea1b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -44,7 +44,7 @@ EXPOSE 3000 # 健康检查 HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \ - CMD curl -f http://localhost:3000/health || exit 1 + CMD curl -f http://localhost:3000/v1/health || exit 1 # 启动应用 CMD ["node", "dist/index.js"] diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 3457ce7..6e220d7 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -22,7 +22,7 @@ services: network_mode: host env_file: .env.prod healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:3000/health"] + test: ["CMD", "curl", "-f", "http://localhost:3000/v1/health"] interval: 30s timeout: 10s retries: 3 @@ -48,7 +48,7 @@ services: network_mode: host env_file: .env.test healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:3001/health"] + test: ["CMD", "curl", "-f", "http://localhost:3001/v1/health"] interval: 30s timeout: 10s retries: 3