How to enforce server-side file validation when using Supabase Storage client-side upload in Next.js?
I have a Next.js app (App Router) with two separate upload paths for a gallery feature, and I realized my server-side security checks are being bypassed. The secure path (Server Action) - validates magic bytes and enforces 10MB limit: // app/actions/upload-gallery-image.ts "use server"; function detectImageType(bytes: Uint8Array): string | null { if (bytes[0] === 0xFF && bytes[1] === 0xD8 && bytes[2] === 0xFF) return "image/jpeg"; if (bytes[0] === 0x89 && bytes[1] === 0x50) return "image/png"; // ... } export async function uploadGalleryImage(formData: FormData) { const file = formData.get("fi
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.