Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/eventyay/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,12 @@ def instance_name(request):
]

STATIC_ROOT = BASE_DIR / 'static.dist'

# Video Vue app: Allow Nginx to serve static assets (opt-in, default: False)
VIDEO_STATIC_NGINX_SERVE = config.getboolean(
'video', 'nginx_serve_static', fallback=False
)

STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
Expand Down
8 changes: 8 additions & 0 deletions app/eventyay/multidomain/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
WEBAPP_DIST_DIR = cast(Path, settings.STATIC_ROOT) / 'webapp'
logger = logging.getLogger(__name__)

# File extensions expected to be served by Nginx when VIDEO_STATIC_NGINX_SERVE is enabled
VIDEO_STATIC_NGINX_EXTENSIONS = {'.js', '.css', '.map'}


def safe_reverse(name: str, **kw) -> str:
try:
Expand Down Expand Up @@ -129,6 +132,11 @@ def default(self, obj):

class VideoAssetView(View):
def get(self, request, path='', *args, **kwargs):
# When VIDEO_STATIC_NGINX_SERVE is enabled, skip serving static assets
if settings.VIDEO_STATIC_NGINX_SERVE and path:
_, ext = os.path.splitext(path.lower())
if ext in VIDEO_STATIC_NGINX_EXTENSIONS:
raise Http404()
# Accept empty path -> index handling done by SPA view
candidate_paths = (
[
Expand Down