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.
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.
You either have a typo in your @Controller() decorator in your controller file, or you haven't registered the controller in the newly created module (moduleName.module.ts file). Those were the most common errors for me.
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...
Run the following commands when you add new routes and controllers.
yarn run build
yarn start
perhaps the app uses a global prefix (app.setGlobalPrefix) and it is easy to forget about it when checking new endpoints
In my case, the route param contains a hyphen which NestJS (or Express?) seems to hate but silently returns 404.
Say, we have GET /foo/1.
This fails because of the hypen.
@Controller('foo/:foo-id')
export class FooController {
@Get('/')
async foo() {}
}
After changing the param name to fooId, it passes.
@Controller('foo/:fooId')
export class FooController {
@Get('/')
async foo() {}
}
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