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

Controller will overwrite another controller with the same name #3645

Closed
xyunsh opened this issue Dec 16, 2019 · 2 comments
Closed

Controller will overwrite another controller with the same name #3645

xyunsh opened this issue Dec 16, 2019 · 2 comments
Labels
needs triage This issue has not been looked into

Comments

@xyunsh
Copy link

xyunsh commented Dec 16, 2019

Input Code

Controller A

import { Controller, Get, Req } from '@nestjs/common';

@Controller('usera')
export class UserController {
  @Get('details')
  details(@Req() request) {
    return request.path;
  }
}

Controller B

import { Controller, Get, Req, Body } from '@nestjs/common';

@Controller('userb')
export class UserController {
  @Get('details')
  details(@Body() body, @Req() request) {
    return request.path;
  }
}

App Module

import { Module } from '@nestjs/common';
import { UserController as AUserController } from './a/user.controller';
import { UserController as BUserController } from './b/user.controller';

@Module({
  controllers: [AUserController, BUserController],
})
export class AppModule {}

http://localhost:3000/usera/details will get 404

if change the order of controllers like:

import { Module } from '@nestjs/common';
import { UserController as AUserController } from './a/user.controller';
import { UserController as BUserController } from './b/user.controller';

@Module({
  controllers: [BUserController, AUserController],
})
export class AppModule {}

http://localhost:3000/userb/details will get 404

there is a repo
https://github.com/xyunsh/samenamed

@xyunsh xyunsh added the needs triage This issue has not been looked into label Dec 16, 2019
@kamilmysliwiec
Copy link
Member

#789

@lock
Copy link

lock bot commented Mar 17, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Mar 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs triage This issue has not been looked into
Projects
None yet
Development

No branches or pull requests

2 participants