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

fix(fastify) New files requires a server restart to be served #523

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SnakeDrak
Copy link

@SnakeDrak SnakeDrak commented May 19, 2021

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[X] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Other... Please describe:

What is the current behavior?

New files are not served using fastify. On this issue or in the documentation of fastify-static is commented that using the wildcard option to false will create only routes to the current files in the system and it will not serve new files.

The issue was introduced on this PR due to the fail of the redirection to the index.

Steps to reproduce it

  • Start with nest/sample/24-servestatic/.
  • Add the FastifyAdapter and start the server.
  • Create a new file, for example test.txt under the static folder client.
  • Try to navigate to /test.txt.

It will redirect to the index.html and the test file will not be served.

What is the new behavior?

The solution is to remove the wildcard option to false by default. However, it would create 404 error when the file doesn't exist and it would not redirect to the index. To solve this latest situation, I have caught the 404 error when they are generated under the renderPath with the fastify adapter to serve the index file, supporting the current behaviour.

Does this PR introduce a breaking change?

[ ] Yes
[X] No

Other information

7rulnik added a commit to 7rulnik/serve-static that referenced this pull request Sep 9, 2021
@7rulnik
Copy link

7rulnik commented Sep 17, 2021

@tristan957 could you take a look at this? We had successfully battle-tested it. For now, it's huge blocker for development with webpack for example.

@tristan957
Copy link

I am not a maintainer, nor am I at all familiar with fastify. Maybe you're meaning to tag someone else

@7rulnik
Copy link

7rulnik commented Sep 17, 2021

Ooops yeah, my bad

Meant to tag @kamilmysliwiec

@rudfoss
Copy link

rudfoss commented Sep 13, 2022

Hi, I've stumbled across the same problem. Any chance of this getting merged? Or at least giving us control over the wildcard parameter?

@jongomes
Copy link

jongomes commented Dec 2, 2022

+1

"@nestjs/platform-fastify": "^9.2.1",
"@fastify/static": "^6.5.1",
"@nestjs/schedule": "^2.1.0",
"@nestjs/serve-static": "^3.0.0",

@ffind
Copy link

ffind commented Mar 3, 2023

Hi, I got the issue with new files are not being served. But there are no way to access wildcard in fastify. So how to serve new files then?

      "@fastify/static": "^6.9.0",
      "@nestjs/serve-static": "^3.0.1",

@wenpeng-song
Copy link

Hi, I've stumbled across the same problem. Any chance of this getting merged? Or at least giving us control over the wildcard parameter?

+1

@ctkc
Copy link

ctkc commented May 28, 2024

Is there a chance we can merge this? I really need it. Thank you @SnakeDrak for the work! cc @kamilmysliwiec

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants