Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redirect doesn't work when preCompressed is true #470

Open
2 tasks done
blue-wing opened this issue Sep 7, 2024 · 1 comment
Open
2 tasks done

redirect doesn't work when preCompressed is true #470

blue-wing opened this issue Sep 7, 2024 · 1 comment
Labels
bug Confirmed bug

Comments

@blue-wing
Copy link

blue-wing commented Sep 7, 2024

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

4.28.1

Plugin version

7.0.4

Node.js version

22.8.0

Operating system

Windows

Operating system version (i.e. 20.04, 11.3, 10)

10

Description

Files:

dir/index.html
dir/index.html.br
main.js

main.js:

import fastifyStatic from "@fastify/static";
import Fastify from "fastify";

const fastify = Fastify({logger: true});
fastify.register(fastifyStatic, {
    root: process.cwd(),
    preCompressed: true,
    redirect: true,
});
fastify.listen({port: 80});

When I navigate to http://localhost/dir, I don't get redirected to http://localhost/dir/ as expected.

The redirection only fails if either dir/index.html or dir/index.html.br exists. If dir is empty, the redirection succeeds and I get a 301 followed by a 404.

Link to code that reproduces the bug

No response

Expected Behavior

The redirection works fine if I comment out the line preCompressed: true.

@mcollina
Copy link
Member

Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.

@mcollina mcollina added the bug Confirmed bug label Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed bug
Projects
None yet
Development

No branches or pull requests

2 participants