Closed IgorRSGraziano closed 3 months ago
sorry but I didn't understand what's wrong. In your reproduction repository, GET http://localhost:3000/user/auth
is returning the response from src/user/user.controller.ts
, as you said it's the expected behavior
Are you saying that it should be returning "Session"
from src/user/auth/auth.controller.ts
instead?
sorry but I didn't understand what's wrong. In your reproduction repository,
GET http://localhost:3000/user/auth
is returning the response fromsrc/user/user.controller.ts
, as you said it's the expected behaviorAre you saying that it should be returning
"Session"
fromsrc/user/auth/auth.controller.ts
instead?
Sorry if the explanation was confusing, when accessing GET http://localhost:3000/user/auth
, you should hit the controller src/user/auth/auth.controller.ts
and not src/user/user.controller
can you share the initial version of the project? could be in another branch of your repository. I didn't understand how the nest ge res ...
and that Auth controller are related to each other
The problem is not in nest g res...
, I just generated it using this resource to have another sampling of the error.
But to be clearer, I created a branch without-resource
without generating this resource
but the src/user/auth/auth.controller.ts
controller doesn't have a user
prefix. Why are you expecting GET /user/auth
to hit that controller? :thinking:
but the
src/user/auth/auth.controller.ts
controller doesn't have auser
prefix. Why are you expectingGET /user/auth
to hit that controller? 🤔
Oh god, sorry, I really forgot about that. But when trying to add user/auth
I had the same error on GET http://localhost:3000/user/auth
AFIAK this is expected. The controllers listed at AppModule
are taking precedence over the ones discovered for each module at AppModule
's imports
.
If you create another module (eg: UserModule
) to register the UserController
controller and then if your AppModule
imports both: [AuthModule, UserModule]
, it will behave as you're expecting due to the registration order.
It worked correctly, thank you very much!
Is there an existing issue for this?
Current behavior
When creating a resource, such as User, which contains a route like
:id
, and within that resource create another resource, let's call it Auth, and the Auth has a root route'/'
, this root route instead of hitting in auth, it is falling on the User routeIn example code, i create manually user (inside src/user), and generated by
nest ge res resource-user
(inside src/resource-user)Minimum reproduction code
https://github.com/IgorRSGraziano/nest-route-override
Steps to reproduce
1 - npm i 2 - npm run start:dev 3 - try access http://localhost:3000/user/auth
Expected behavior
Expected result from example code is 'Session' response (from controller src/user/user.controller.ts)
Package
Other package
No response
NestJS version
10.0.0
Packages versions
Node.js version
21.2.0
In which operating systems have you tested?
Other
No response