【发布时间】:2018-11-28 11:40:01
【问题描述】:
我正在使用 react 和 node 构建一个 crud 应用程序,所以我需要检查每个请求是否存在 cookie。
app.all("*", (req,res) => {
// cookie doesn't exist redirect to login
if(cookieExist(req.headers.cookie)){
// how to pass to the next layer ? load the routes below code etc..
next();
}else{
res.redirect("/login")
}
})
const routes = require("./routes/route");
app.use(bodyParser.json());
app.use(cors());
app.use("/apiServices", apiRoutes)
我在这里缺少什么,得到未定义的 next()。
【问题讨论】:
-
但我得到 next() 未定义?
标签: javascript node.js express