koa session does not work when used in a middleware app
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 908
- Forks
- 115
- PR merge metrics
- No merged PRs in 30d
Description
I am using the vhost middleware with koa-session. Since koa-session 2.0.0 is was possible to use it in a subapp. Since 3.0.0 this does not work anymore. Example:
var session = require('./');
var koa = require('koa');
var compose = require('koa-compose');
var app = koa();
app.keys = ['some secret hurr'];
app.use(session(app));
app.use(function* (next){
if ('/favicon.ico' == this.path) return;
var n = this.session.views || 0;
this.session.views = ++n;
this.body = n + ' views';
});
var server = koa();
server.use(compose(app.middleware));
server.listen(3000);
console.log('listening on port 3000');
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the koa-session 3.0.0 middleware entry point and reproduce the issue using the example with koa, koa-compose, and vhost-style subapp composition. Trace why session setup differs from 2.0.0, then verify that the same session behavior works when the app middleware is composed into the parent server.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100