I’ve been banging my head against the wall on this…
Some context:
- I’m developing an ioS app
- I have offloaded all Supabase interactions to a REST API built in NestJS
- I have a user profile context within the app
- I send a JWT to the API which is inspected and from which the Supabase Auth User ID value is extracted (this is the ‘sub’ in the JWT)
- I give this user ID to Supabase via the .eq() method of the database call
- RLS is active on the table
The issue is that this workflow works from one context but not another:
- I can successfully use a PUT request to the API to update the profile from a HTTP client (I’m using Insomnia)
- When I make this same API call from within the iOS app everything is apparently successful except the the database update is not committed.
I have tried disabling RLS but the update is again:
- successful from Insomnia
- failing from iOS
- I use the same JWT in both contexts so rule out security failures with the API
- Tokens are not expired
- Keeping or removing RLS on the table has no effect
- Reviewing logs doesn’t show anything abnormal
- Reviewing header values, whilst different between the platforms, doesn’t indicate anything thats wrong
…
Given the platform I have described it’s difficult to share any code that might indicate where a problem lies. I in fact don’t think it’s my code… but there is nothing anywhere to suggest what is causing the update to fail.
A small block of code just to illustrate the failure point:
const response = await Client.connection
.from(this.tableName)
.update({
"given_name": updateProfileDto.givenName,
"family_name": updateProfileDto.familyName
})
.eq("user_id", this.session.getUser()) // <--- this is a UUID
.select()
return { message: "Updated", data: response.data }
The short of it is that the write of the update does not occur when triggered from the iOS context, but does when called from Insomnia.
If anyone has any thought on what I could investigate I’d love to hear from you!