TypeError:this.keys.index 不是函数
控制台日志显示 if 条件行是错误的
app.get('/',(req,res)=>{
if(!req.session.authenticated){
res.redirect('/login');
}else{
res.redirect('/search')
}
})
直到我从一个完全不同的文件夹启动另一个 server.js 之前都很好。我试图重新安装 node_module 来修复它,但结果是一样的。但奇怪的是我可以毫无问题地在 vm 中启动服务器。有什么可以帮助我的吗?
Cookies.prototype.get = function(name, opts) {
var sigName = name + ".sig"
, header, match, value, remote, data, index
, signed = opts && opts.signed !== undefined ? opts.signed : !!this.keys
header = this.request.headers["cookie"]
if (!header) return
match = header.match(getPattern(name))
if (!match) return
value = match[1]
if (!opts || !signed) return value
remote = this.get(sigName)
if (!remote) return
data = name + "=" + value
if (!this.keys) throw new Error('.keys required for signed cookies');
index = this.keys.index(data, remote)
if (index < 0) {
this.set(sigName, null, {path: "/", signed: false })
} else {
index && this.set(sigName, this.keys.sign(data), { signed: false })
return value
}
};