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

Nest-Router Adding Additional Slash before Controller #53

Closed
willcooley opened this issue Mar 7, 2019 · 4 comments
Closed

Nest-Router Adding Additional Slash before Controller #53

willcooley opened this issue Mar 7, 2019 · 4 comments

Comments

@willcooley
Copy link

willcooley commented Mar 7, 2019

Issue:
In the Logs, when Nestjs goes to compile, an additional slash is being added before the module's controller. This can be verified by hitting the url route. If one were to go to /api/v1/auth/, you would get a 404, but the path in the url /api/v1/auth// works as a status 200.

Terminal Log Path on Compiling:
[Nest] 21099 - 3/6/2019, 7:27:44 PM [RoutesResolver] AuthController {/api/v1/auth//}: +0ms

What it should be:
[Nest] 21099 - 3/6/2019, 7:27:44 PM [RoutesResolver] AuthController {/api/v1/auth/}: +0ms

Router Object:
`

 // ROUTES
 const routes: Routes = [ {
	     path: '/api',
	     children: [ {
		path: '/v1',
		children: [
		     { path: '/auth', module: AuthModule }
	         ]
             }]
     }];

`

Controller:
`

 import { Controller } from '@nestjs/common';

 @Controller()
 export class AuthController {

   @Get()
   returnSomething() {}

 }

`

Auth Module:
`

 import { Module } from '@nestjs/common';

 // Controllers
 import { AuthController } from './auth.controller';


 @Module({
    controllers: [ AuthController ]
 })
 export class AuthModule {}

`

@willcooley
Copy link
Author

willcooley commented Mar 7, 2019

well.... I believe the issue has to deal with nestjs itself, and not nest-router after more debugging.... nestjs/nest#1594 as mentioned in another ticket. I fixed nestjs router issue, and it works fine now; so I guess it's to wait until that ticket is closed and released. Basically, nestjs is adding a base path in on '/' if nothing is specified it seems, and the base and path when added are inverted possibly.

@willcooley
Copy link
Author

willcooley commented Mar 7, 2019

for the interim, i used node package module called patch-package, and then fixed the file. After fixing the file, I ran the command npx patch-package @nestjs/core to patch it until it was fixed.

https://www.npmjs.com/package/patch-package

@shekohex
Copy link
Member

shekohex commented Mar 8, 2019

Yup, it's a bug in the nest core, and already reported to nestjs, and it's fixed, but not yet released.

I will hold this issue until Kamil release that version with the fix.

@shekohex
Copy link
Member

I think this is also fixed as of nestjs/nest#1594 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants