Skip to content

Option to redirect requests for directory. #92

@coreyfarrell

Description

@coreyfarrell

Take the following files within the root directory:

index.html
sub/index.html

Configure fastify-static to include index: 'index.html'. In this case http://localhost/ serves the root index.html, http://localhost/sub/ serves sub/index.html. But http://localhost/sub is a 404 error. Would you accept an option that would hook send.on('directory') to perform a 301 redirect of such requests to the path including the trialing slash? Such that http://localhost/sub would be 301 with Location: http://localhost/sub/. I haven't tested this yet but the send documentation tells how to accomplish this. I'm assuming that directory redirects would need to be opt-in rather than opt-out? Either would be fine with me, just figured I'd ask since fastify-static is in the middle of a semver-major release.

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