Fix media file access for single-machine deployment without reverse proxy - #12732
Open
chinaglowing wants to merge 2 commits into
Open
Fix media file access for single-machine deployment without reverse proxy#12732chinaglowing wants to merge 2 commits into
chinaglowing wants to merge 2 commits into
Conversation
✅ Deploy Preview for inventree-web-pui-preview canceled.
|
matmair
requested changes
Aug 28, 2026
Member
There was a problem hiding this comment.
I don't know where you think you added authorisation checks for media files. I don't see it and there are no checks so this is a hard pass without proper docs and tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In single-machine deployments without a reverse proxy (e.g., Windows standalone with SQLite), media files (exported reports, labels, etc.) return 404 errors. Additionally, media file requests are blocked by the security middleware.
Changes
middleware.py(+3 lines)Add
MEDIA_URLtopaths_own_security- media files are served with DRF token / session auth in single-machine mode, so they need to bypass the default auth middleware redirect.urls.py(+14 lines, -4 lines)Serve media files via
django.views.static.serveoutsideDEBUGmode. Previously, media file routing was only configured whenDEBUG = True, which means production/single-machine deployments without a reverse proxy had no way to access media files.The new
re_pathserves media files at/media/<path>using Django's built-in static serve view, with authentication handled byAuthRequiredMiddleware+ DRF token/session auth.Testing
Notes