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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user