Skip to content

Fix middleware auth: handle Supabase unreachable gracefully#18

Merged
kutcode merged 2 commits into
mainfrom
feature/security-and-new-features
Mar 27, 2026
Merged

Fix middleware auth: handle Supabase unreachable gracefully#18
kutcode merged 2 commits into
mainfrom
feature/security-and-new-features

Conversation

@kutcode

@kutcode kutcode commented Mar 27, 2026

Copy link
Copy Markdown
Owner

Summary

  • The server-side Next.js middleware was calling supabase.auth.getUser() which returned {"detail":"Not Found"} when Supabase wasn't reachable from the server context (e.g., Docker internal URL mismatch)
  • Now wraps the auth check in try/catch and falls through to client-side auth on any error
  • Checks for missing env vars before attempting the server-side call

Test plan

  • Login with valid credentials → should redirect to /admin without errors
  • Access /admin without session → should redirect to /admin/login

🤖 Generated with Claude Code

kutcode and others added 2 commits March 27, 2026 00:03
…ured

The server-side middleware was hard-failing with {"detail":"Not Found"}
when Supabase wasn't reachable from the server context. Now falls through
to client-side auth on any error instead of blocking login entirely.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…e auth

The middleware runs server-side inside the frontend container where
localhost:8000 is unreachable (it refers to the container itself, not
the host). Added SUPABASE_URL env var pointing to supabase-kong:8000
for Docker networking, and the middleware now prefers it over the
browser-facing NEXT_PUBLIC_SUPABASE_URL.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@kutcode kutcode merged commit 5f587bf into main Mar 27, 2026
4 checks passed
kutcode added a commit that referenced this pull request Mar 27, 2026
Fix middleware auth: handle Supabase unreachable gracefully
@kutcode kutcode deleted the feature/security-and-new-features branch March 28, 2026 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant