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
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:
@ -60,16 +60,16 @@ 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
|
||||||
|
|
||||||
if [ -z "$COMMIT_MSG" ]; then
|
if [ -z "$COMMIT_MSG" ]; then
|
||||||
COMMIT_MSG="Deploy: $(date '+%Y-%m-%d %H:%M')"
|
COMMIT_MSG="Deploy: $(date '+%Y-%m-%d %H:%M')"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git commit -m "$COMMIT_MSG" || true
|
git commit -m "$COMMIT_MSG" || true
|
||||||
echo " ✓ Committed: $COMMIT_MSG"
|
echo " ✓ Committed: $COMMIT_MSG"
|
||||||
fi
|
fi
|
||||||
|
|||||||
57
frontend/src/app/api/health/route.ts
Normal file
57
frontend/src/app/api/health/route.ts
Normal 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
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user