From cd067ee5dafa5f7a76fb1adcb30bb4b8d184e936 Mon Sep 17 00:00:00 2001 From: Egor fureunoir Gorbunov Date: Mon, 10 Nov 2025 11:51:34 +0300 Subject: [PATCH] Features: 1) Add static files configuration in nginx for cross-origin requests. Fixes: 1) Update Console styling in 'initialize' command to remove non-standard style notice; 2) Simplify STATIC_URL and MEDIA_URL definitions in settings for uniformity. Extra: 1) Minor cleanup in static and media path handling; 2) Add new location block in nginx for static files access. --- engine/core/management/commands/initialize.py | 2 +- evibes/settings/base.py | 12 ++---------- nginx.conf | 5 +++++ 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/engine/core/management/commands/initialize.py b/engine/core/management/commands/initialize.py index faf35ec9..e1c7e2bb 100644 --- a/engine/core/management/commands/initialize.py +++ b/engine/core/management/commands/initialize.py @@ -12,7 +12,7 @@ logger = logging.getLogger(__name__) class Command(BaseCommand): def handle(self, *args: list[Any], **options: dict[Any, Any]) -> None: - self.stdout.write(self.style.NOTICE("Initializing must-have instances...")) + self.stdout.write("Initializing must-have instances...") Vendor.objects.get_or_create(name="INNER") Group.objects.all() diff --git a/evibes/settings/base.py b/evibes/settings/base.py index 3b08748c..a2eda7cd 100644 --- a/evibes/settings/base.py +++ b/evibes/settings/base.py @@ -292,18 +292,10 @@ DEFAULT_AUTO_FIELD: str = "django.db.models.BigAutoField" TIME_ZONE: str = getenv("TIME_ZONE", "Europe/London") -STATIC_URL: str = ( - f"http://api.{getenv('EVIBES_BASE_DOMAIN')}/static/" - if DEBUG - else f"https://api.{getenv('EVIBES_BASE_DOMAIN')}/static/" -) +STATIC_URL: str = "/static/" STATIC_ROOT: Path = BASE_DIR / "static" -MEDIA_URL: str = ( - f"http://api.{getenv('EVIBES_BASE_DOMAIN')}/media/" - if DEBUG - else f"https://api.{getenv('EVIBES_BASE_DOMAIN')}/media/" -) +MEDIA_URL: str = "/media/" MEDIA_ROOT: Path = BASE_DIR / "media" AUTH_USER_MODEL: str = "vibes_auth.User" diff --git a/nginx.conf b/nginx.conf index f5937cdd..c58a355d 100644 --- a/nginx.conf +++ b/nginx.conf @@ -137,6 +137,11 @@ server { default_type text/plain; } + location /static/ { + add_header Access-Control-Allow-Origin "*"; + root /var/jenkins/workspace/evibes; + } + location /favicon.ico { add_header Access-Control-Allow-Origin "*"; root /var/jenkins/workspace/evibes/static;