'nestjs returns 404 not found for 1 routes working fine for others

I am using nestjs to create an API, quite new to it. I created 4 modules and all 4 seem to be working fine. I created another module name steps but all routes I access in it returns 404 not found.



Solution 1:[1]

when after add new routes and controllers, we should clean up dist folder and restart yarn start:dev to make sure the added fils work...

Solution 2:[2]

perhaps the app uses a global prefix (app.setGlobalPrefix) and it is easy to forget about it when checking new endpoints

Solution 3:[3]

Got this trouble using a jwt as a route parameter findByJwt/:jwt with a string "toto" it works, with a jwt nestjs return a 404

Solution 4:[4]

Run the following commands when you add new routes and controllers.

yarn run build
yarn start

Solution 5:[5]

In my case, the route param contained a hyphen, which NestJS (or Express?) seemed to hate and stuck to return 404.

@Controller('foo/:foo-id')
export class FooController {

  @Get('/')
  async foo() {}
}

After changing the param name to fooId, GET /foo/1 started returning 200.

@Controller('foo/:fooId')
export class FooController {

  @Get('/')
  async foo() {}
}

Solution 6:[6]

extending @Bruno's answer for new user. Make sure all your modules are added to import

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 zyfyy
Solution 2
Solution 3
Solution 4 Zahirul Haque
Solution 5
Solution 6 SZT