Skip to content

Commit bc2d7be

Browse files
committed
fix: allow /api/health without auth session + fix post-deploy verify script
1 parent 92eae76 commit bc2d7be

2 files changed

Lines changed: 59 additions & 1 deletion

File tree

middleware.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ export default withAuth(
1414
const url = req.nextUrl.clone();
1515

1616
if (!token) {
17-
if (authRoutes.some((r) => pathname.startsWith(r))) {
17+
if (
18+
authRoutes.some((r) => pathname.startsWith(r)) ||
19+
pathname.startsWith("/api/health")
20+
) {
1821
return addSecurityHeaders(NextResponse.next(), requestId);
1922
}
2023
url.pathname = "/login";

scripts/post-deploy-verify.sh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env bash
2+
# Post-deploy verification script
3+
# Usage: bash scripts/post-deploy-verify.sh <domain>
4+
set -eo pipefail
5+
6+
DOMAIN="${1:-https://teos-ai-engine.vercel.app}"
7+
PASS=0
8+
FAIL=0
9+
10+
check() {
11+
local label="$1" expected="$2" actual="$3"
12+
if [[ "$actual" == "$expected" ]]; then
13+
echo "$label"
14+
PASS=$((PASS + 1))
15+
else
16+
echo "$label — expected $expected, got $actual"
17+
FAIL=$((FAIL + 1))
18+
fi
19+
}
20+
21+
echo "=== Post-Deploy Verification: $DOMAIN ==="
22+
echo ""
23+
echo "--- Security Headers ---"
24+
25+
HDRS=$(curl -sI "$DOMAIN/login" 2>/dev/null)
26+
27+
check "CSP present" "1" "$(echo "$HDRS" | grep -ci "^content-security-policy:" || true)"
28+
check "HSTS present" "1" "$(echo "$HDRS" | grep -ci "^strict-transport-security:" || true)"
29+
check "X-Frame-Options DENY" "1" "$(echo "$HDRS" | grep -ci "x-frame-options: deny" || true)"
30+
check "X-Content-Type-Options nosniff" "1" "$(echo "$HDRS" | grep -ci "x-content-type-options: nosniff" || true)"
31+
check "X-Request-ID present" "1" "$(echo "$HDRS" | grep -ci "^x-request-id:" || true)"
32+
check "Permissions-Policy present" "1" "$(echo "$HDRS" | grep -ci "^permissions-policy:" || true)"
33+
34+
echo ""
35+
echo "--- Route Behavior ---"
36+
37+
check "Login /login → 200" "200" "$(curl -s -o /dev/null -w '%{http_code}' "$DOMAIN/login" 2>/dev/null)"
38+
check "Health /api/health → 200" "200" "$(curl -s -o /dev/null -w '%{http_code}' "$DOMAIN/api/health" 2>/dev/null)"
39+
check "Generate (no auth) → 307|401" "1" "$(curl -s -o /dev/null -w '%{http_code}' -X POST "$DOMAIN/api/generate" -H 'Content-Type: application/json' -d '{}' 2>/dev/null | grep -cE '307|401' || true)"
40+
41+
echo ""
42+
echo "--- Correlation ID ---"
43+
check "X-Request-ID on /api/health" "1" "$(curl -sI "$DOMAIN/api/health" 2>/dev/null | grep -ci "^x-request-id:" || true)"
44+
45+
echo ""
46+
echo "=== Results ==="
47+
echo "Passed: $PASS"
48+
echo "Failed: $FAIL"
49+
echo ""
50+
51+
if [ "$FAIL" -gt 0 ]; then
52+
echo "⚠️ Some checks failed — review above."
53+
else
54+
echo "✅ All checks passed!"
55+
fi

0 commit comments

Comments
 (0)