Give uploads one path end to end, and serve /uploads/ from Garage first
Frontend: src/uploads.js is the one way to store or show a file (uploadFile, ACCEPT, kindOf, isUploadUrl, tagFor, mediaSize). Chat, the box editor, canvas drops and the background editor all use it; views/home3/upload.js and the chat store's own axios call are gone. Backend: POST /api/uploads (was /messages/upload) is a thin wrapper over services.Uploads.Save, which owns validation, naming and storage. The three per-extension maps are now one UploadTypes table, and a refused file is an *UploadError whose message is safe to show. nginx now fetches /uploads/ from Garage first and falls back to the volume on a 404 or any 5xx, so the bucket is the source of truth and deleting a file in garage-webui unpublishes it, while a Garage outage still only affects bucket-only files. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -83,8 +83,8 @@
|
||||
set $upstream_usaco http://usaco:8080;
|
||||
# And the Dozzle log viewer's.
|
||||
set $upstream_dozzle http://dozzle:8080;
|
||||
# Garage: its website endpoint (the /uploads/ bucket fallback, used by
|
||||
# the @uploads_bucket location in nginx.conf.template and
|
||||
# Garage: its website endpoint (where /uploads/ is served from; see the
|
||||
# /uploads/ location in nginx.conf.template and
|
||||
# nginx_dev_common.conf.template) and the garage-webui admin UI.
|
||||
set $upstream_garage_web http://garage:3902;
|
||||
set $upstream_garage_webui http://garage-webui:3909;
|
||||
@@ -115,7 +115,7 @@
|
||||
# breaking auth behind TLS termination.
|
||||
#
|
||||
# Ordering matters: nginx picks the longest matching prefix location,
|
||||
# so the specific /ws, /auth/login and /messages/upload blocks (and
|
||||
# so the specific /ws, /auth/login and /uploads blocks (and
|
||||
# production's /graphql block in nginx.conf.template) win over the
|
||||
# catch-all <PREFIX>/ block regardless of file order.
|
||||
location $BACKEND_ENDPOINT {
|
||||
@@ -154,7 +154,7 @@
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
location $BACKEND_ENDPOINT/messages/upload {
|
||||
location $BACKEND_ENDPOINT/uploads {
|
||||
limit_req zone=upload burst=20 nodelay;
|
||||
rewrite ^$BACKEND_ENDPOINT/(.*)$ /$1 break;
|
||||
proxy_pass $upstream_backend;
|
||||
|
||||
Reference in New Issue
Block a user