diff --git a/deploy.sh b/deploy.sh index 4b04f13..9aac4f9 100755 --- a/deploy.sh +++ b/deploy.sh @@ -60,16 +60,16 @@ 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 - + if [ -z "$COMMIT_MSG" ]; then COMMIT_MSG="Deploy: $(date '+%Y-%m-%d %H:%M')" fi - + git commit -m "$COMMIT_MSG" || true echo " ✓ Committed: $COMMIT_MSG" fi diff --git a/frontend/src/app/api/health/route.ts b/frontend/src/app/api/health/route.ts new file mode 100644 index 0000000..4192e13 --- /dev/null +++ b/frontend/src/app/api/health/route.ts @@ -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 + ) + } +} +