How to test function that requires service key locally #37524
Unanswered
AndreLiu1225
asked this question in
Questions
Replies: 2 comments
|
Two things to check:
curl -i http://127.0.0.1:54321/functions/v1/my-func \
-H "Authorization: Bearer <anon key from supabase status>"For a function you call from cron or a webhook, you can skip verification:
|
0 replies
|
One more thing that jumps out from your command: the header is missing the colon. Without the colon curl doesn't form an HTTP header, so no Then a second trap when moving from cloud to local:
A 30-second sanity check that separates header bugs from JWT bugs: call the function locally with the local anon key and the corrected header. If you get data back, the cloud service key was never the problem. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I've been testing a function that fetches data from a 3rd party API and saves it to my database in supabase. However, I cannot seem to get past the authentication part as running CURL always returns an invalid jwt error.
CODE
COMMAND
curl -X POST "<function_url>" -H "Authorization Bearer <service_role_key>"MESSAGE
{"msg":"Invalid JWT"}%
All reactions