From bbef07c825f40bc03f5991568b85a3401de37c0b Mon Sep 17 00:00:00 2001 From: Local Dev Date: Thu, 22 Oct 2026 23:20:19 +0300 Subject: [PATCH] prometheus: 200 MiB upload cap + Caddy block fix for the "<" error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two bugs under one roof. The visible one: a publisher uploading anything over 10 MB on the live site got "Network error — Unexpected token '<'" in the browser console. Cause: the Caddy block I wrote for prometheus.x had `request_body { max_size 2GB }` nested inside the handle block, where it is a syntax Caddy parses but does not apply, so Caddy's own 10 MB default was still the gate. Any oversize POST got Caddy's HTML 413 page, which the browser's JSON parser choked on at the leading `<`. Fix: moved `request_body { max_size … }` to the top of the prometheus.x site block (outside `handle`), where Caddy actually honours it. The live Caddyfile on p2pexchange is already patched + reloaded; a 50 MB upload verified through the end-to-end path (Caddy → service → clamd → signed scan report). The scope one: 2 GiB was more than Prometheus should offer to publishers at launch. Mobile apps are usually ~100 MB and even most desktop installers come in well under 200 MiB. Dropping to 200 MiB: - Fits every Android APK and most desktop installers. - Shrinks the operator's Sia storage bill (fewer accidental Steam-size uploads). - Keeps the "publishers of larger binaries self-host and submit a manifest with the external URL + SHA" escape hatch — the scanner still fetches the URL and checks the hash, so a 5 GB game isn't locked out, Prometheus just doesn't eat its storage. Changes: service/uploads.js MAX_FILE_BYTES default: 2 GiB → 200 MiB service/pages.js /submit step-1 subtitle: "any size up to 2 GiB" → "up to 200 MiB" deploy/prometheus-x.conf (unused angie fallback) 2g → 200m deploy/apps-silentmode-st.conf (unused angie fallback) 2g → 200m PROMETHEUS_MAX_UPLOAD_BYTES env still overrides per-instance. --- deploy/apps-silentmode-st.conf | 6 +++--- deploy/prometheus-x.conf | 7 ++++--- service/pages.js | 2 +- service/uploads.js | 10 +++++++--- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/deploy/apps-silentmode-st.conf b/deploy/apps-silentmode-st.conf index 2732a6c..b7f85b6 100644 --- a/deploy/apps-silentmode-st.conf +++ b/deploy/apps-silentmode-st.conf @@ -36,9 +36,9 @@ server { proxy_set_header X-Forwarded-Proto https; proxy_set_header X-Forwarded-Host apps.silentmode.st; - # Large publisher uploads need a generous ceiling — matches the service's - # own 2 GiB cap. Reads are small; this governs POST /api/upload. - client_max_body_size 2g; + # Matches the service's 200 MiB upload cap. Reads are small; this + # governs POST /api/upload. + client_max_body_size 200m; proxy_request_buffering off; # The service's own long-cache headers decide for static assets; this diff --git a/deploy/prometheus-x.conf b/deploy/prometheus-x.conf index 667ccf4..8e5197b 100644 --- a/deploy/prometheus-x.conf +++ b/deploy/prometheus-x.conf @@ -36,9 +36,10 @@ server { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; - # Publishers upload binaries that can be hundreds of MB. 2 GiB - # matches the service's own cap in uploads.js. - client_max_body_size 2g; + # 200 MiB fits Android APKs and most desktop installers; matches the + # service's own cap in uploads.js. Publishers of larger binaries + # self-host and submit a manifest with the external URL + SHA. + client_max_body_size 200m; proxy_request_buffering off; proxy_buffering off; diff --git a/service/pages.js b/service/pages.js index 2fa736c..262268d 100644 --- a/service/pages.js +++ b/service/pages.js @@ -321,7 +321,7 @@ export function submit() {
    -
  1. Upload the binary (any size up to 2 GiB)
  2. +
  3. Upload the binary (up to 200 MiB)
  4. Describe name, publisher name, category, description
  5. Sign with the BCH key for your publisher BNS name
  6. Publish POST to the directory
  7. diff --git a/service/uploads.js b/service/uploads.js index ce016d6..e9e18f9 100644 --- a/service/uploads.js +++ b/service/uploads.js @@ -36,10 +36,14 @@ import { signReport } from './signing.js'; const UPLOAD_DIR = process.env.PROMETHEUS_UPLOAD_DIR || resolve(dirname(fileURLToPath(import.meta.url)), '..', 'uploads'); -// 2 GiB — the ceiling, not the typical size. Change via env rather than code -// so an operator can tighten it without a redeploy. +// 200 MiB — fits every Android APK and most desktop installers; publishers +// of larger binaries self-host and submit a manifest with the external URL + +// SHA. The service's cap and Caddy's `request_body { max_size 200MB }` on +// the prometheus.x vhost must stay in sync — if Caddy rejects first, the +// browser gets an HTML 413 page that the JSON parser cannot read. +// Change via env rather than code so an operator can tighten per-instance. const MAX_FILE_BYTES = Number(process.env.PROMETHEUS_MAX_UPLOAD_BYTES) - || 2 * 1024 * 1024 * 1024; + || 200 * 1024 * 1024; /** * Express-style handler attached to `/api/upload`.