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

Mounting a sub-app onto a router doesn't emmit the 'mount' event. #3285

Closed
tomasgvivo opened this issue Apr 23, 2017 · 1 comment
Closed
Assignees

Comments

@tomasgvivo
Copy link

tomasgvivo commented Apr 23, 2017

How to reproduce:

var express = require('express');
var subapp = express();
var app = express();

subapp.on('mount', () => {
    console.log('mounted');
})

app.use('/subapp', subapp);

app.listen(8080);
=> mounted

but

var express = require('express');
var subapp = express();
var app = express();

subapp.on('mount', () => {
    console.log('mounted');
})

var router = express.Router();

router.use('/subapp', subapp);
app.use(router);

app.listen(8080);
no log :P
@dougwilson
Copy link
Contributor

Yes, this is working as intended. An app is only "mounted" on another app. Adding an app to a router does not run through the same semantics, namely how it links together the settings, locals, and more. This is as designed.

I hope this helps!

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

No branches or pull requests

2 participants