From 83b00cbb35c4b8cd00c2a5c7459fbfb9863390c6 Mon Sep 17 00:00:00 2001 From: elijahbenizzy Date: Sun, 30 Jun 2024 13:33:22 -0700 Subject: [PATCH] Allows static files to be served in non-debug mode There is a simple flag that allows it. While we really should be not using the django server, this is OK for now. This is necessary as django does not, by default, serve static files in non-debug mode. We want that to happen so someone can run this. We will be providing a more production-blessed path soon, but this unblocks our users. --- ui/backend/server/commands.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ui/backend/server/commands.py b/ui/backend/server/commands.py index 8353321f5..936285aee 100644 --- a/ui/backend/server/commands.py +++ b/ui/backend/server/commands.py @@ -126,8 +126,13 @@ def run( env = {**_load_env(config_file), **env} with set_env_variables(env): settings_file_param = f"--settings={settings_file.value}" + # execute_from_command_line(["manage.py", "collectstatic", settings_file_param]) if not no_migration: execute_from_command_line(["manage.py", "migrate", settings_file_param]) execute_from_command_line( - ["manage.py", "runserver", settings_file_param, f"0.0.0.0:{port}"] + # Why insecure? Because we're running locally using django's server which + # is not specifically meant for production. That said, we'll be fixing this up shortly, + # but for now, users who want to run this not in debug mode and serve it will want to use this: + # See https://stackoverflow.com/questions/5836674/why-does-debug-false-setting-make-my-django-static-files-access-fail + ["manage.py", "runserver", settings_file_param, f"0.0.0.0:{port}", "--insecure"] )