Β© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabaseβ€’7mo agoβ€’
8 replies
Hugo

invalid api key

🚨 Auth Failure in Production (401 "Invalid API Key") – Need Help

Hi team, I'm running into a critical authentication failure with Supabase on my production deployment (Netlify). Hoping someone can help or escalate:

πŸ” Problem Summary
βœ… Localhost (localhost:3000) β€” Auth works perfectly
❌ Production (*.netlify.app) β€” Fails on sign-in with 401 Unauthorized (Invalid API Key)
πŸ” Consistently reproducible across all users and devices

πŸ”‘ Key Observations
-The anon API key works for DB queries (e.g., fetching profiles).
-Only the Supabase Auth service is returning 401 on /auth/v1/token?grant_type=password.
-Environment variables are correct β€” VITE_SUPABASE_URL and VITE_SUPABASE_ANON_KEY match the dashboard and load in production.
-Netlify is correctly routing β€” UI loads, but auth API fails.
-Multiple auth flows fail β€” PKCE and password-based login both return 401.
-Have not tried rotating JWT signing key β€” doing so would break critical edge functions, so I’m holding off.
-Support ticket already submitted β€” I'm a paid Pro user and awaiting a reply from the Supabase team.

πŸ§ͺ What I’ve Tried (but didn’t fix it)
-Vite config tweaks
-Netlify redirect rules
-Circular dependency fixes
-UI cleanup
-RLS policy adjustments
-Bypassing custom edge functions
-Full project restart
(Details omitted here, but happy to provide full audit if needed.)

🧠 Suspected Root Cause
Could this be tied to a bug related to the JWT signing key update? I suspect the Auth microservice is misconfigured or rejecting valid anon keys for grant_type=password flows β€” despite the same key working for DB operations.

πŸ“£ Ask
Can someone from the Supabase team please:
-Confirm if this could be infra-related?
-Help validate whether a migration or auth service reset is needed?
-Suggest any other safe debugging steps (short of rotating the JWT signing key)?

We’re completely blocked in production. Grateful for any guidance β€” happy to DM logs or network traces if helpful.

Thanks in advance!
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Invalid API Key Next.js
SupabaseSSupabase / help-and-questions
6mo ago
api key
SupabaseSSupabase / help-and-questions
3y ago
invalid api keys
SupabaseSSupabase / help-and-questions
8mo ago
API key Failed
SupabaseSSupabase / help-and-questions
5mo ago