Deploy: add /api/health route + fix deploy git detection
Some checks failed
CI / Frontend Lint & Type Check (push) Has been cancelled
CI / Frontend Build (push) Has been cancelled
CI / Backend Lint (push) Has been cancelled
CI / Backend Tests (push) Has been cancelled
CI / Docker Build (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
Deploy / Build & Push Images (push) Has been cancelled
Deploy / Deploy to Server (push) Has been cancelled
Deploy / Notify (push) Has been cancelled

This commit is contained in:
2025-12-15 14:14:02 +01:00
parent c16afe468f
commit 1cb4b64646
2 changed files with 61 additions and 4 deletions

View File

@ -60,8 +60,8 @@ fi
if ! $QUICK_MODE; then if ! $QUICK_MODE; then
echo -e "\n${YELLOW}[1/4] Git operations...${NC}" echo -e "\n${YELLOW}[1/4] Git operations...${NC}"
# Check for changes # Check for changes (including untracked)
if git diff --quiet && git diff --staged --quiet; then if [ -z "$(git status --porcelain)" ]; then
echo " No changes to commit" echo " No changes to commit"
else else
git add -A git add -A

View File

@ -0,0 +1,57 @@
export const dynamic = 'force-dynamic'
function jsonResponse(body: unknown, status: number) {
return new Response(JSON.stringify(body), {
status,
headers: {
'content-type': 'application/json; charset=utf-8',
'cache-control': 'no-store',
},
})
}
export async function GET() {
const backendBase = (process.env.BACKEND_URL || 'http://127.0.0.1:8000').replace(/\/$/, '')
const url = `${backendBase}/health`
try {
const res = await fetch(url, { cache: 'no-store' })
const text = await res.text()
let backend: unknown = text
try {
backend = JSON.parse(text)
} catch {
// keep text
}
if (!res.ok) {
return jsonResponse(
{
status: 'degraded',
frontend: { ok: true },
backend: { ok: false, status: res.status, body: backend },
},
503
)
}
return jsonResponse(
{
status: 'ok',
frontend: { ok: true },
backend: { ok: true, body: backend },
},
200
)
} catch (err) {
return jsonResponse(
{
status: 'down',
frontend: { ok: true },
backend: { ok: false, error: err instanceof Error ? err.message : String(err) },
},
503
)
}
}