Skip to content

Commit

Permalink
move DispatcherMiddleware after custom /static
Browse files Browse the repository at this point in the history
This allows custom static files to work with an APPLICATION_ROOT.
  • Loading branch information
bouttier committed Sep 25, 2023
1 parent 06215f0 commit d6aeb7f
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions backend/geonature/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,18 @@ def create_app(with_external_mods=True):
app.wsgi_app = SchemeFix(app.wsgi_app, scheme=config.get("PREFERRED_URL_SCHEME"))
app.wsgi_app = ProxyFix(app.wsgi_app, x_host=1)
app.wsgi_app = RequestID(app.wsgi_app)
if app.config["APPLICATION_ROOT"] != "/":
app.wsgi_app = DispatcherMiddleware(
Response("Not Found", status=404),
{app.config["APPLICATION_ROOT"].rstrip("/"): app.wsgi_app},
)

if config.get("CUSTOM_STATIC_FOLDER"):
app.wsgi_app = SharedDataMiddleware(
app.wsgi_app,
{
"/static": config["CUSTOM_STATIC_FOLDER"],
},
)
if app.config["APPLICATION_ROOT"] != "/":
app.wsgi_app = DispatcherMiddleware(
Response("Not Found", status=404),
{app.config["APPLICATION_ROOT"].rstrip("/"): app.wsgi_app},
)

app.json = MyJSONProvider(app)

Expand Down

0 comments on commit d6aeb7f

Please sign in to comment.