Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix(studio): raise body size limit for saving SQL snippets (#47032)

obchain7007a8e5e87c
diff --git a/apps/studio/pages/api/platform/projects/[ref]/content/index.ts b/apps/studio/pages/api/platform/projects/[ref]/content/index.ts
index 53718b73d12..bf700e882f0 100644
--- a/apps/studio/pages/api/platform/projects/[ref]/content/index.ts
+++ b/apps/studio/pages/api/platform/projects/[ref]/content/index.ts
@@ -12,6 +12,17 @@ import {
updateSnippet,
} from '@/lib/api/snippets.utils'
+// Next.js defaults the API body parser to a 1mb limit, which rejects large SQL
+// snippets (e.g. multi-thousand-line RPCs) with a 413 before they can be saved.
+// Match the 5mb limit already used by the AI SQL endpoint.
+export const config = {
+ api: {
+ bodyParser: {
+ sizeLimit: '5mb',
+ },
+ },
+}
+
const wrappedHandler = (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
async function handler(req: NextApiRequest, res: NextApiResponse) {