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
Dynamic SCRIPT_NAME and compressed assets #1197
Comments
From PR #876, it looks like I'm supposed to add my own class that dynamically adds the SCRIPT_NAME prefix to the STATIC_URL (and COMPRESS_URL) (or am I supposed to use the |
This looks like you're hitting this issue in Django... https://code.djangoproject.com/ticket/34028 The long and short is that script name doesn't really work outside of the request-response cycle, so not with compress. You might need to adjust your static url when running the command (or else find a way of making it work) |
Thanks, @carltongibson. I actually don't have any static url in the compressed asset itself - this is just an issue with linking to the compressed asset when the response is generated. I tried adding the So it looks like the feature does work, if the user adds a |
Following the discussion on the linked Django issue, in this circumstance Maybe it's an issue with Django, maybe it's a configuration issue, but a minimal reproduce on a fresh project, and a report to Django is likely the way to go. I don't think it's a compressor issue per se? 🤔 (Using the utility from compressor's test suite looks like patching over any issue, rather than addressing it 😬) |
Reviewing the docs for https://docs.djangoproject.com/en/4.2/ref/settings/#force-script-name Update: Although the gunicorn FAQ seems to imply either would be good: https://docs.gunicorn.org/en/stable/faq.html — you'll need to experiment to pin down exactly the behaviour. |
@carltongibson thanks again for your comments. Here's a question: if I want to mount my app at different prefixes (eg. What I'm seeing locally is that if I set COMPRESS_URL to a regular value like |
Grr. I'd have to play. (And there's not enough info, or a quick reproduce here, so that I can do that.) I'd reckon per-deploy settings with slight tweaks would do it. (I saw you commented about the offline context on another issue...) |
Here's a playground project: https://github.com/bcail/dj_playground. I'm running it with: Here's my nginx config:
|
This is using Django 4.2.3, django-compressor 4.4, and gunicorn 20.1.0. I'm trying out the dynamic SCRIPT_NAME feature (PR #876), but I'm having trouble getting it working.
I have a gunicorn app running on localhost:8000, and it's proxied through nginx at /app. Here's the nginx config:
I ran the
compress
command.When I hit a view on my app, I can see that SCRIPT_NAME is correctly coming through as
/app
, but the URL to the compressed static file is still just/static/...
, without the/app
prefix. Shouldn't the URL to the compressed static file be updated with the SCRIPT_NAME prefix?From my settings file:
The text was updated successfully, but these errors were encountered: