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

When upgrading from 5.7.3 to 6.0.0, using FastifyAdapter produces 404 Not Found for all routes #1703

Closed
Tsury opened this issue Mar 17, 2019 · 7 comments

Comments

@Tsury
Copy link

commented Mar 17, 2019

Using the default express adapter works fine.

Code:

import { NestFactory } from '@nestjs/core';
import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify';
import { AppModule } from './app.module';

const bootstrap = async () => {
  const app = await NestFactory.create<NestFastifyApplication>(AppModule, new FastifyAdapter());
  await app.listen(3000, '0.0.0.0');
};

bootstrap().then().catch();

Simply removing FastifyAdapter makes everything work fine again.
Tried removing node_modules, cleairng cache etc.

Currently reverted to 5.7.4 where everything works fine with FastifyAdapter

@jmcdo29

This comment has been minimized.

Copy link

commented Mar 17, 2019

I thought this was just me and a way I had my code set up. Initializing a new nest app with nest new fastify-test and adding the fastify adapter doesn't seem to break it though, so far as I could tell.

@BrunnerLivio

This comment has been minimized.

Copy link
Member

commented Mar 17, 2019

@truewt

This comment has been minimized.

Copy link

commented Mar 18, 2019

I also came across this issue and tried the proposed solution. However there is no any difference with 404 response. To reproduce the issue - I downloaded 6.0.0 archive from GitHub releases subpage and extracted the contents on my system. Then I moved to the samples/10-fastify, commented out controller guard for cats and ran npm install + npm start. I visited both http://localhost:3000/cats and http://localhost:3000/cats/ in different browsers, with different/random sequence of entering URLs (first with trailing slash and after that without it). I'm still getting 404 and can't get the right answer with fastify - with express everything works as expected. I'm having the same problem with the endpoint which is specified for Swagger docs.

@kamilmysliwiec

This comment has been minimized.

Copy link
Member

commented Mar 18, 2019

@truewt thanks. For some reason it seems that app starts working correctly when you simulate the first HTTP request:

  await app.listen(3000);
  await app
    .getHttpAdapter()
    .getInstance()
    .inject({
      method: 'GET',
      url: '/cats',
    });

then, each subsequent request will work. Will dig into this issue.

kamilmysliwiec added a commit that referenced this issue Mar 18, 2019
@kamilmysliwiec

This comment has been minimized.

Copy link
Member

commented Mar 18, 2019

It should be fixed in 6.0.1 :) Please, let me know if you encounter any issues.

@truewt

This comment has been minimized.

Copy link

commented Mar 18, 2019

Now it works as expected.

Not related to this issue, but after testing routing I figured out that Swagger is not compatible with fastify after separation of express from core (so with v6). Is this ok (since after fast lookup of Swagger package, it depends on express) or should there be a fastify based Swagger package? If anything related to that should be contributed I can try to arrange my team to look at this.

@kamilmysliwiec

This comment has been minimized.

Copy link
Member

commented Mar 18, 2019

@truewt I'll take care of swagger module shortly. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.