请问,在auth.js的中间件中,获取的ctx.session是空对象,并没有像视频中那样获取到值,这是怎么回事?
module.exports = options => {
return async (ctx, next) => {
const url = ctx.request.url;
const user = ctx.username;
// console.log("user1==>", JSON.stringify(ctx.session)); 此处为空对象??
if(!user && !options.exclude.includes(ctx.request.url.split('?')[0])) {
ctx.body = {
status: 1001,
errMsg: '用户未登录'
}
}else {
await next();
}
}
}