# Notifications Troubleshooting and Fix ## Symptoms - Notifications screen fails to load and logs show a `GET | 401` response from `supabase/functions/v1/notifications`. - Edge function logs show `Unauthorized` even though the client is signed in. ## Root Cause The notifications edge function relied on `supabaseClient.auth.getUser()` without explicitly passing the bearer token from the request. In some cases, the global headers were not applied as expected, so `getUser()` could not resolve the user and returned 401. ## Fix Explicitly read the `Authorization` header and pass the token to `supabaseClient.auth.getUser(token)`. This ensures the function authenticates the user consistently even if the SDK does not automatically inject the header. ## Code Change File: `supabase/functions/notifications/index.ts` Key update: - Parse `Authorization` header. - Extract bearer token. - Call `getUser(token)` instead of `getUser()` without arguments. ## Deployment Step Redeploy the `notifications` edge function so the new auth flow is used. ## Verification - Open the notifications screen. - Confirm the request returns 200 and notifications render. - If it still fails, check edge function logs for missing or empty auth headers.