Route resolving fails when setGlobalPrefix() is used
See original GitHub issueHi Shekohex, after some trial and error I think nest-router is having issues when a globalPrefix is set in bootstrap function.
Let’s say my routes look like this:
const routes:Routes = [
{
path: '/test',
module: TestBackendModule
}
];
Combined with this
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.setGlobalPrefix(`api`);
await app.listen(3333);
}
Neither calls to /api/test nor calls to /test could be routed successfully. After removing the call to setGlobalPrefix, calls to /test were routed to the TestBackendModule. Is this behaviour intended? If so, may I recommend to add a note to the Readme.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Global prefix for a module / route tree #255 - nestjs/nest - GitHub
Hi, there is an older issue, which got implemented: #40 - allowing to setGlobalPrefix('api') on the app instance.
Read more >NestJs returns 404 on all routes when deployed with nginx but ...
I configured ingress-nginx to send all traffic visiting /api/ over to my backend (NestJS app). The issue was that the /api/ part was...
Read more >Global prefix - FAQ | NestJS - A progressive Node.js framework
Global prefix. To set a prefix for every route registered in an HTTP application, use the setGlobalPrefix() method of the INestApplication instance.
Read more >[V2] Holyjs 2019 - Nestjs. Tried To Shift In 80 Hours
error ? reject(error) : resolve(result) ... For example, most components can be re-used ... [Nest] - [RouterExplorer] Mapped {/, GET} route +3ms.
Read more >Getting started | tsoa - GitHub Pages
Configuring tsoa and typescript; Defining our first model; Defining a simple controller; Creating our express server; Building the routes file; What's next?
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Is there a workaround to this? Only thing I can think of fixing nest’s router, and keeping the package local until something is done. I’m in a tight squeeze to have this fixed by tomorrow. Any ideas? Is there anyway to override nest’s router method for the fix to be used, instead of using what is currently there? I’ve lost a bunch of time trying to figure this out sadly, lol.
Fixed as of https://github.com/nestjs/nest/pull/1594 🎉