Use WSGI SCRIPT_NAME (request.script_root) for file urls instead of requests_pathname_prefix
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 24.4k
- Forks
- 2.3k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 13
Description
Is your feature request related to a problem? Please describe.
Dash currently requires setting requests_pathname_prefix when hosting under a sub-path for generating file URLs, despite the fact that the WSGI spec and Flask offer a provision for this by the way of the SCRIPT_NAME variable (Available in Flask in request.script_root) and used by Flask utilities like url_for when in request context by default.
There is also routes_pathname_prefix which is effected by SCRIPT_NAME adding to the confusion.
The is obviously all very confusing.
Describe the solution you'd like
Use SCRIPT_NAME via request.script_root to generate file URLs, removing the need to change requests_pathname_prefix probably deprecating it. Backwards compatibility concerns apply.
Describe alternatives you've considered
Keep having to manually set requests_pathname_prefix in each app, which also requires modifying the app source file today.
Additional context
SCRIPT_NAME & PATH_INFO needs to be set correctly by the combination of WSGI server and proxy. The way to do so varies.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing how Dash uses requests_pathname_prefix and routes_pathname_prefix when generating file URLs, then compare that behavior with Flask's request.script_root from WSGI SCRIPT_NAME. Verify file URLs when the app is hosted under a sub-path and determine how existing requests_pathname_prefix behavior can remain compatible or be deprecated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- flask, python
- Domain
- backend, web-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100