mounted app.context doesn't get applied to parent app
Example:
const mount = require('koa-mount');
const Koa = require('koa');
const a = new Koa();
a.context.test = "hallo";
a.use(async function (ctx, next){
ctx.body = "test:" + ctx.test;
return next();
});
// app
const app = new Koa();
app.use(mount('/hello', a));
app.listen(3000)
a.listen(3001);
http://localhost:3000/hello results in test:hallo
http://localhost:3001/hello results in test:undefined
Having this exact issue. Middleware should be configurable to be hierarchical.
It's more than just app.context, mounting bypasses all context initialization performed at https://github.com/koajs/koa/blob/master/lib/application.js#L175
Try sending a request over https:// to a mounted app, and checking ctxt.request.secure
This module fundamentally breaks Koa, it is incompatible. When mounting Koa applications https://github.com/koajs/mount#mounting-applications, it should use callback() to make sure the correct processing happens (at https://github.com/koajs/mount/blob/master/index.js#L36)
@jbemmel can you provide a PR?
Hi Philipp, In my opinion the problem is with Koa - it has a complex implicit structure that is non-intuitive, and module writers easily get things wrong. I have decided that Koa is not something I want to invest in