Fix club logo 404 in production and persist uploads

/media/* was only routed when DEBUG=True, so uploaded club logos
404d in production regardless of storage backend. Route it whenever
local-disk storage is in use instead, and give web a persistent
volume for MEDIA_ROOT so uploads survive a rebuild.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-06 20:41:33 +02:00
parent 30b464eb56
commit 5b8ab72982
4 changed files with 25 additions and 4 deletions

View File

@@ -39,5 +39,10 @@ if settings.DEBUG:
if settings.BROWSER_RELOAD_AVAILABLE:
urlpatterns += [path("__reload__/", include("django_browser_reload.urls"))]
# Club logos are uploads: runserver has to serve MEDIA_ROOT itself.
if not settings.AWS_STORAGE_BUCKET_NAME:
# Gated on the storage backend, not on DEBUG: local disk is the default until a bucket is
# configured (see settings.STORAGES), and Caddy only reverse-proxies — it never serves
# /media/* itself — so without this route every uploaded club logo 404s in production too.
# Once AWS_STORAGE_BUCKET_NAME is set, club.logo.url points straight at the bucket and this
# route is simply never hit.
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)