-
-
Notifications
You must be signed in to change notification settings - Fork 597
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error handling request to static files #1878
Comments
I'm seeing this as well using the "plain" docker-compose setup. Setting According to https://code.djangoproject.com/ticket/25598 when STATIC_URL and MEDIA_URL are relative SCRIPT_NAME is supposed to be automatically injected, which doesn't appear to be happening but I'm not sure why. edit: I added some debugging statements to the Django code and it looks like it does see the SCRIPT_NAME prefix when serving a request, but the app initializes with an empty SCRIPT_NAME value and that gets cached in Django application config, so subsequent calls to |
I think Django broke this functionality since adding it in 2019 because application settings appear to be cached in a dict now. |
ok thanks for reporting! |
After a bunch of debugging, this appears to be related to whitenoise middleware. Django's will inspect SCRIPT_NAME header or FORCE_SCRIPT_NAME setting to set the internal prefix, which is then applied to STATIC_URL and MEDIA_URL -- however, these settings all get cached based on the first access to these settings. Normally that would be the very first HTTP request to the Django server and all would be well; but whitenoise attempts to access STATIC_URL during initialization; of course being outside a HTTP request context, there's no SCRIPT_NAME header to read so the prefix is just "/" and gets cached that way. That's why the pathing is correct but all the static URLs are wrong. |
Has anyone found a workaround? |
Thank you for looking into that. However, following https://docs.tandoor.dev/install/other/ and in particular, reading issue #266 with its modifications to the
|
@danieldietsch I think I had the same static file problem and the same solution. And I too have only the webfonts issue remaining. Looking at the code, it seems the webfonts' urls are hardcoded in the theme. For example here :
It seems these paths are not modified by the settings in the |
@danieldietsch any chance you'd be willing to share your docker/nginx configuration? I've been trying at this a while and haven't been able to make anything work :( |
Please open a new issue and share your configuration and logs. |
@ncovercash I did not pursue this any further. I didn't get the fonts working, and it was unusable for me. |
as a workaround for subfolder you have to serve static content with nginx or some other web server |
Issue
I am just setting up Tandoor with docker compose and an external reverse proxy in a subfolder.
So far, I can access
https://domain/recipes/setup/
, but all requests to static assets fail with the following error.It seems I am missing the right combination of the various URLs in the .env file. I have
Without setting
STATIC_URL
andMEDIA_URL
, the requests get rewritten tohttps://domain/static
instead ofhttps://domain/recipes/static
, and hence rejected by Apache.Do you know how this could be fixed?
Tandoor Version
latest
OS Version
Gentoo
Setup
Docker / Docker-Compose
Reverse Proxy
Others (please state below)
Other
Apache 2.4.54
Environment file
DEBUG=0 SQL_DEBUG=0 HTTP_PORT=127.0.0.1:8281 ALLOWED_HOSTS=* TIMEZONE=Europe/Berlin DB_ENGINE=django.db.backends.postgresql POSTGRES_HOST=db_recipes POSTGRES_PORT=5432 POSTGRES_USER=djangouser POSTGRES_DB=djangodb FRACTION_PREF_DEFAULT=0 COMMENT_PREF_DEFAULT=1 SHOPPING_MIN_AUTOSYNC_INTERVAL=5 SCRIPT_NAME=/recipes STATIC_URL=recipes/static/ MEDIA_URL=recipes/media/ GUNICORN_MEDIA=0 REVERSE_PROXY_AUTH=0 ENABLE_PDF_EXPORT=1
Docker-Compose file
Relevant logs
see above
The text was updated successfully, but these errors were encountered: