Skip to content

Option to prepend a path for redirects in ServeDir #487

@claraphyll

Description

@claraphyll
  • 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions