You're getting this error when uploading images:
StorageApiError: new row violates row-level security policy
This means the Supabase Storage bucket "pages" doesn't have permission policies to allow uploads.
- Open your browser
- Go to
https://supabase.com/dashboard - Select your project:
iqiijwnxixnucpsatweq
- Click on Storage in the left sidebar
- Look for a bucket named "pages"
- If it doesn't exist:
- Click "New Bucket"
- Name it "pages"
- Toggle "Public bucket" to ON
- Click "Create Bucket"
- Click on SQL Editor in the left sidebar
- Click "New Query"
- Copy and paste the contents of this file:
supabase/FIX_STORAGE_RLS_COMPLETE.sql - Click RUN (bottom right)
- Wait for success message
- Go back to your admin panel:
http://localhost:5173/admin - Select an issue
- Try uploading an image to a page
- It should work now!
The script creates 4 policies:
- Admin upload to pages - Allows authenticated users to INSERT (upload) files
- Admin update pages - Allows authenticated users to UPDATE files
- Admin delete from pages - Allows authenticated users to DELETE files
- Public read pages - Allows EVERYONE to READ (view) files
- ✅ Image uploads work
- ✅ No more "row violates row-level security policy" errors
- ✅ 3D book displays uploaded images correctly
- ✅ Public users can see book pages (because bucket is public)
-- Run this in SQL Editor to verify policies exist:
SELECT policyname, cmd
FROM pg_policies
WHERE schemaname = 'storage'
AND tablename = 'objects'
AND policyname LIKE '%pages%';You should see 4 rows:
- Admin upload to pages (INSERT)
- Admin update pages (UPDATE)
- Admin delete from pages (DELETE)
- Public read pages (SELECT)
While you fix the Storage RLS, I've also improved the code:
- Upload errors now properly throw instead of silently failing
- Prevents invalid URLs from being added to cache
- Shows clear error messages in browser
- All form inputs now use
?? ""instead of allowing undefined - Prevents React warnings about controlled/uncontrolled inputs
Issue: Bucket doesn't exist Solution:
- Go to Storage
- Create bucket named "pages"
- Make it public
- Run SQL again
Issue: You're not logged in Solution:
- Make sure you're logged into admin panel
- Check browser console for auth errors
Issue: RLS policies didn't apply Solution:
- Check SQL Editor for error messages
- Try running each policy creation individually
- Check if policies already exist (drop them first)
supabase/FIX_STORAGE_RLS_COMPLETE.sql← Run this in Supabase!src/context/BookDataContext.jsx- Better upload error handlingsrc/components/Dashboard.jsx- Fixed controlled input warnings
YOU MUST DO THIS:
- Open Supabase Dashboard
- Go to SQL Editor
- Run
supabase/FIX_STORAGE_RLS_COMPLETE.sql - Test image upload in admin panel
Without this, image uploads will continue to fail!
The code is ready, but Supabase storage permissions need to be configured on your end.