© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•3y ago•
7 replies
Christian

"Invalid API key" when querying from Edge Function, but not when querying directly

Hello,
I've created an Edge Function to handle storage uploads, but it will not accept my users auth key. I have made a simple RLS policy on the buckets which checks if the user is authenticated.

When I query the storage directly I supply the Bearer with the users 'access-token' and the Anon key as API key and it lets me upload a file.
But when doing it through the Edge Function with the exact same auth key as the bearer, it gives me the "Invalid API key" error. When passing the the anon/service key with Bearer, it works.

Am I missing something or do I need to pass the ANON key when creating the client?
image.png
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

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Edge Function returning 500 when querying table (Supabase)
SupabaseSSupabase / help-and-questions
11h ago
invalid api key
SupabaseSSupabase / help-and-questions
7mo ago
Edge function giving Invalid JWT
SupabaseSSupabase / help-and-questions
7mo ago
Cannot access new service role API key from Edge Function runtime
SupabaseSSupabase / help-and-questions
3mo ago