[x] I have looked for existing issues (including closed) about this
Feature Request
Motivation
Currently ServeDir assumes that the files are served from /, which breaks trailing slash redirects in some configurations like a reverse proxy that redirects /somePath/* to the ServeDir server or a scenario where axum::Router::nest_service is used.
Proposal
Allow this to be configured, see #486
Alternatives
NormalizePathLayer doesn't work, since it removes the trailing slash and hence always triggers the TSR. Whether to perform the redirect depends on the files served (whether the requested path leads to a file or directory) so it seems reasonable to implement this in ServeDir.
A similar argument applies to axum_extras function route_with_tsr
Feature Request
Motivation
Currently ServeDir assumes that the files are served from /, which breaks trailing slash redirects in some configurations like a reverse proxy that redirects /somePath/* to the ServeDir server or a scenario where
axum::Router::nest_service
is used.Proposal
Allow this to be configured, see #486
Alternatives
NormalizePathLayer
doesn't work, since it removes the trailing slash and hence always triggers the TSR. Whether to perform the redirect depends on the files served (whether the requested path leads to a file or directory) so it seems reasonable to implement this inServeDir
.A similar argument applies to
axum_extra
s functionroute_with_tsr