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