If you're experiencing upload failures, try these simplified storage policies first:
- Go to Supabase Dashboard → Storage
- Click "New bucket"
- Name:
wardrobe-images - Make it PUBLIC ✅
- Click "Create bucket"
Go to the bucket → Policies tab and add these policies:
- Policy name:
Allow all uploads - Target roles:
anon - Policy definition:
true - Check expression:
bucket_id = 'wardrobe-images'
- Policy name:
Allow all downloads - Target roles:
anon - Policy definition:
true - Check expression:
bucket_id = 'wardrobe-images'
- Policy name:
Allow all deletions - Target roles:
anon - Policy definition:
true - Check expression:
bucket_id = 'wardrobe-images'
- Visit
http://localhost:3000/test-storage - Click "Test Storage Connection"
- Click "Test Image Upload"
- Check the results
Solution: Make sure the bucket name is exactly wardrobe-images (case-sensitive)
Solution:
- Make sure the bucket is marked as PUBLIC
- Add the simple policies above
- Check that you're using the
anonrole in policies
Solution:
- Go to Settings → API
- Add
http://localhost:3000to CORS origins - Restart your development server
Solution:
- Check the bucket's file size limit
- Make sure it's set to at least 10MB
- Or reduce the file size limit in the code
For production, replace the simple policies with more restrictive ones:
-- Allow users to upload their own files
CREATE POLICY "Users can upload own files" ON storage.objects
FOR INSERT WITH CHECK (
bucket_id = 'wardrobe-images' AND
auth.uid()::text = (storage.foldername(name))[1]
);
-- Allow users to view their own files
CREATE POLICY "Users can view own files" ON storage.objects
FOR SELECT USING (
bucket_id = 'wardrobe-images' AND
auth.uid()::text = (storage.foldername(name))[1]
);
-- Allow users to delete their own files
CREATE POLICY "Users can delete own files" ON storage.objects
FOR DELETE USING (
bucket_id = 'wardrobe-images' AND
auth.uid()::text = (storage.foldername(name))[1]
);But for now, use the simple policies to get uploads working first!