whitenoise
whitenoise copied to clipboard
Revert change to use get_script_prefix
Hello :wave:
This reverts this change https://github.com/evansd/whitenoise/pull/259 which added the use of get_script_prefix
in the middleware init.
Unfortunately this function is not designed to be used outside the request response cycle and as middleware is initialised outside of that, this is causing unexpected results. For now reverting this change is the best solution to resolve this issue https://github.com/evansd/whitenoise/issues/271 :+1:
Note: You can see here a suggestion to have a better way to access this outside the request response cycle is being discussed
@evansd @adamchainz I've now added a changelog, I think this is ready for a review :+1:
@sarahboyce Can you give some clarification on what "unexpected results" you are seeing with the current implementation?
@sarahboyce Can you give some clarification on what "unexpected results" you are seeing with the current implementation?
This should be mostly captured by this ticket to Django: https://code.djangoproject.com/ticket/34028
get_script_prefix
is designed to be only used in the request response cycle. Here is is being used in the Middleware init (so during setup) and as a result settings such as FORCE_SCRIPT_NAME
are not respected
Thanks for the clarification. Working on getting it merged within ServeStatic
, a fork of WhiteNoise for continued maintenance and feature updates.
To leave some breadcrumbs just incase the WhiteNoise maintainers one day revisit the PR backlog:
- The tests in this PR needed some love.
- This PR needs some documentation updates to
SERVESTATIC_STATIC_PREFIX
- Everything else is otherwise looking good.