Skip to content

fix: raise nginx's upload body size limit past its 1MB default - #71

Merged
JustSamuel merged 1 commit into
mainfrom
fix/nginx-upload-body-size-limit
Aug 18, 2026
Merged

fix: raise nginx's upload body size limit past its 1MB default#71
JustSamuel merged 1 commit into
mainfrom
fix/nginx-upload-body-size-limit

Conversation

@JustSamuel

Copy link
Copy Markdown
Collaborator

Summary

Root cause of the "could not connect to server" reports on mobile photo uploads: nginx's compiled-in client_max_body_size default is 1MB, and frontend/nginx/default.conf never overrode it, even though the app's own upload caps go up to 50MB (video). nginx rejects the request with a 413 before the backend ever sees it -- and because the client is often still mid-upload when nginx closes the connection, browsers can surface that as a raw network failure rather than a clean HTTP error, which is what made this look like a connectivity problem instead of a size limit.

A real phone photo is almost always well over 1MB, so this failed reliably in production while never showing up in this session's own testing -- the Vite dev proxy used all session has no such limit at all, only the production nginx config does.

Root cause evidence

Reproduced locally with the real nginx image and the exact /api/ proxy config, pointed at the actual backend:

  • 2MB file straight to the backend (bypassing nginx): 401 (bad token, but the full body reached the handler)
  • Same file through nginx, unpatched: 413 Request Entity Too Large, 0 bytes uploaded
  • Same file through nginx, with client_max_body_size 60m; added: 401, full body uploaded -- matches the direct-to-backend result
  • 70MB file through the patched config: still cleanly 413 -- the raised limit is bounded, not disabled

Test plan

  • Reproduced the bug and verified the fix with the real nginx image (see above)
  • Change is a single config line; no application code touched

Root cause of "could not connect to server" on mobile photo uploads:
nginx's own compiled-in client_max_body_size default (1MB) is smaller
than the app's own upload caps (up to 50MB for video), and nothing in
default.conf ever overrode it. nginx rejects the request with a 413
before it reaches the backend at all -- and because the client is
often still mid-upload when that happens, the browser can see it as a
raw connection failure rather than a clean HTTP error, which is what
made this look like a network problem instead of a size limit.

Confirmed via a local repro: the exact same 2MB file that the backend
accepts directly gets a 413 through nginx's default config, and
succeeds once this override is in place. Never caught during
development because the Vite dev proxy used all session has no such
limit -- only the production nginx config does.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@JustSamuel
JustSamuel enabled auto-merge (rebase) August 18, 2026 12:25
@github-actions

Copy link
Copy Markdown

Coverage Report for frontend

Status Category Percentage Covered / Total
🔵 Lines 88.35% 1312 / 1485
🔵 Statements 85.91% 1440 / 1676
🔵 Functions 83.3% 454 / 545
🔵 Branches 81.39% 884 / 1086
File CoverageNo changed files found.
Generated in workflow #114 for commit 6e08ce8 by the Vitest Coverage Report Action

@JustSamuel
JustSamuel merged commit c8d56c8 into main Aug 18, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant