-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
fix(platform): added prefix to adapters #4186
base: master
Are you sure you want to change the base?
Conversation
Pull Request Test Coverage Report for Build 16357
💛 - Coveralls |
Does this also still add a
Would it be possible to keep that, as that is the current functionality? And what happens if no global prefix is set by either application? Does the first application have it's route handler overwritten? |
In addition to @jmcdo29 questions, what if I have a single app + I set the global prefix to, let's say, |
@jmcdo29 @kamilmysliwiec |
Maybe we should simply add 2 additional properties to the application options interface which will determine whether to mount the "not found" and "exception handler" middleware. Hence, you would be able to compose multiple applications easily. |
I changed to keep the globalprefix set by httpadapter. example
result
When prefix is not added + prefix is added, it works normally. But it's a bit complicated
This is fine, but which one do you prefer? |
Example: const server = express();
const adapter = new ExpressAdapter(server);
const catsApp = await NestFactory.create(AppModule, adapter, {
notFoundHandler: false,
});
const dogsApp = await NestFactory.create(AppModule, adapter);
catsApp.setGlobalPrefix('cats');
dogsApp.setGlobalPrefix('dogs');
await catsApp.init();
await dogsApp.init();
server.listen(3000, () => console.log('Listening at 3000')); In this case, the If one wants to disable it entirely, const catsApp = await NestFactory.create(AppModule, adapter, {
notFoundHandler: false,
});
const dogsApp = await NestFactory.create(AppModule, adapter, {
notFoundHandler: false,
}); |
What would happen if someone set |
I also think the same issue occur. Could you review the commit for |
Probably not. We can't really determine whether it was set on purpose or not. I think setting the |
If catsApp is set
So We can't get access to I will make two proposals below. Plan 1This add NotFoundHandler to the "/" route and prefix route.
Plan 2This add NotFoundHandler to the prefix route only.
And user need to add the
|
I'm sorry. I want to solve this problem. If you proceed with adding properties, there is a possibility that it can be solved by creating a new method. Example:
What do you think? |
any updates? |
fixes #4114
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
When launching multiple NestApplication instances for a single adapter and using
setGlobalPrefix
for each, the router of the instance that executed theinit
method later cannot be used.example
result
Issue Number: #4114
What is the new behavior?
When setting middreware to the adapter, set the prefix registered with
setGlobalPrefix
.With the above measures, the middleware is set for each instance, and the router is set appropriately.
Does this PR introduce a breaking change?
If we do not use
setGlobalPrefix
, if we set with '/' added, if we set without '/', everything works normally.This has been adapted to maintain compatibility.
Other information