nuxt3 & supabase safety
hey, i use supabase with nuxt3, when i do inserts to supabase should i make this via api? How secure is the javascript in my .vue files. I have following code in my pages/events.vue to create an event
Can this code be modified from client side to maybe change that
user.value.id
? If yes i think this is more safe to do it via api where the user id gets set on server side to prevent users posting as another user if they have the id
maybe i could to it with serverSupabaseClient
https://supabase.nuxtjs.org/usage/services/server-supabase-client
the demo uses also the client side stuff inside the vue files https://github.com/nuxt-modules/supabase/blob/main/demo/pages/tasks.vueGitHub
supabase/tasks.vue at main · nuxt-modules/supabase
Supabase module for Nuxt. Contribute to nuxt-modules/supabase development by creating an account on GitHub.
2 Replies
You need to use RLS to enforce the userid column equals auth.uid() on insert for it to be safe. You can also set default on the database side to auth.uid() for the column, but still need RLS to keep it from being changed. Note the API can be called without your code at all so you need to have some sort of RLS protection anyway.
Okay, thank you @garyaustin