title: how to check every request have the cookie in express js
body: <p>I am building a crud application using react and node , so i need to check for every request whether the cookie is present or not. </p>
  
  <pre><code>app.all("*", (req,res) =&gt; {
   // 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)
  </code></pre>
  
  <p>what i am missing here, getting next() as not defined.</p>