Replies: 2 comments
|
The error "JWSError (JSONDecodeError Not valid base64url)" means the SUPABASE_SERVICE_ROLE_KEY in your environment is malformed or missing. The service role key is a JWT that must be set in your .env file as the full token string, not the anon key: SUPABASE_URL=https://your-project.supabase.co In nuxt.config.ts, map the variable: supabase: { Then serverSupabaseServiceRole(event) will pick up the correct key. The most common cause of the base64url error on Windows paths (like your D:/Projects path) is that the key in .env was truncated or accidentally wrapped across a line. Check that SUPABASE_SERVICE_KEY is a single unbroken string. |
|
The JWSError "Not valid base64url" from serverSupabaseServiceRole means the service role JWT value that the module is reading at runtime is malformed. The function reads the SUPABASE_SERVICE_KEY environment variable and passes it directly to the Supabase client constructor, which then tries to decode it as a JWT. If the value contains extra whitespace, a newline, or any character that is not valid base64url, the decoder throws this error. A few things to check in order. First, open your .env file and look at the SUPABASE_SERVICE_KEY line. Make sure there are no trailing spaces, no line continuation characters, and no surrounding quotes. Some editors and copy-paste operations from the Supabase dashboard add a trailing newline. Second, confirm you are using the service_role key and not the anon key. Go to your Supabase project dashboard, open Project Settings, then API. The service_role key is labeled service_role and is longer than the anon key. Using the anon key where the service role key is expected will produce the same error. Third, if you are using pnpm, add a quick log at the top of your handler to verify the runtime value: console.log("KEY_LENGTH:", process.env.SUPABASE_SERVICE_KEY?.length)
console.log("KEY_START:", process.env.SUPABASE_SERVICE_KEY?.substring(0, 20))Compare the logged length to what you see in the dashboard. A mismatch confirms the .env value is getting truncated or modified somewhere in the environment loading chain. Once the environment variable has the correct unmodified value from the dashboard, the error will disappear without any code changes. |
Uh oh!
There was an error while loading. Please reload this page.
I am getting this response when I tried to use the function:
It is throwing this error:
All reactions