Я создаю грубое приложение, использующее реагирование и узел, поэтому для каждого запроса мне нужно проверять, присутствует ли 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 () как не определено.