From d90f8bd645a26174b2981034be6f2587ccf1cc3b Mon Sep 17 00:00:00 2001 From: vance Date: Thu, 9 Apr 2026 22:53:14 -0700 Subject: [PATCH] Raise mobile upload limits --- apps/submission/src/features/submission/api.ts | 14 +++++++++++++- docker/nginx/spa.conf | 1 + services/api/src/server.ts | 4 ++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/apps/submission/src/features/submission/api.ts b/apps/submission/src/features/submission/api.ts index aba9bfa..daaa9d4 100644 --- a/apps/submission/src/features/submission/api.ts +++ b/apps/submission/src/features/submission/api.ts @@ -21,6 +21,12 @@ export const createSubmission = async ( onProgress?: (progress: number) => void ): Promise => new Promise((resolve, reject) => { + const maxUploadBytes = 64 * 1024 * 1024; + if (input.file.size > maxUploadBytes) { + reject(new Error("That image is too large for the current upload limit. Please choose a smaller photo.")); + return; + } + const formData = new FormData(); formData.append("file", input.file); formData.append("displayName", input.displayName ?? ""); @@ -48,7 +54,13 @@ export const createSubmission = async ( return; } - reject(new Error((request.response as { message?: string } | null)?.message ?? "Upload failed.")); + const responseMessage = (request.response as { message?: string } | null)?.message; + if (request.status === 413) { + reject(new Error("That image is too large for the current upload limit. Please choose a smaller photo.")); + return; + } + + reject(new Error(responseMessage ?? `Upload failed (${request.status || "network"}).`)); }); request.addEventListener("error", () => { diff --git a/docker/nginx/spa.conf b/docker/nginx/spa.conf index 587d310..25d4e0b 100644 --- a/docker/nginx/spa.conf +++ b/docker/nginx/spa.conf @@ -1,6 +1,7 @@ server { listen 80; server_name _; + client_max_body_size 64m; root /usr/share/nginx/html; index index.html; diff --git a/services/api/src/server.ts b/services/api/src/server.ts index 8f64d4b..7b0716b 100644 --- a/services/api/src/server.ts +++ b/services/api/src/server.ts @@ -214,7 +214,7 @@ const createSubmissionFromMultipart = async ( export const buildServer = async () => { const app = Fastify({ logger: true, - bodyLimit: 25 * 1024 * 1024 + bodyLimit: 64 * 1024 * 1024 }); const store = new StateStore(config.stateFile); @@ -265,7 +265,7 @@ export const buildServer = async () => { await app.register(multipart, { limits: { files: 1, - fileSize: 25 * 1024 * 1024 + fileSize: 64 * 1024 * 1024 } }); await app.register(fastifyStatic, {