question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Route resolving fails when setGlobalPrefix() is used

See original GitHub issue

Hi 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:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
willcooleycommented, Mar 7, 2019

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.

0reactions
shekohexcommented, Mar 10, 2019
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found