title: Node js (Express ) express.static is not working
body: <p>I am working on a small app in which I just logging user using Gmail account. Problem is when user login successfully into app there is redirect to other page which gives error 404.</p>
  
  <p>Directory hierarchy is like <a href="https://i.stack.imgur.com/LpUnt.jpg" rel="nofollow noreferrer">enter image description here</a></p>
  
  <p>And Ejs files are in view folder</p>
  
  <p>I When User login by google account It should be Redirected to Welcome page But it gives an error Page not found.</p>
  
  <p>Default page code is below </p>
  
  <pre><code>    "use strict"
      const path=require("path");
      const express=require("express");
      const session=require("express-session");
      const bodyParser=require("body-parser");
      const passport = require("passport");
      const db   =require("./DbConnection/findCollection");
      const auth = require("./auth");
      const compression = require("compression");
      var appDir = path.dirname(require.main.filename);
  
      const app=express();
      app.set("view engine", "ejs");
  
      app.use(bodyParser.urlencoded({extended:true}));
  
      //enable gzip
      app.use(compression()); 
      //enable session storage
      //TODO: add connect-mongo as session storage
      app.use(session({
          resave: false,
          saveUninitialized: false,
          secret:"keyboardcat",//config.get("SECRET"),
          signed: true
      }));
      app.all("*", (req, res, next) =&gt; {
          console.log("request: " + req.url);
          next();
      });
      //OAuth
      app.use(passport.initialize());
      app.use(passport.session());
      app.use(auth.router);
  
      function respond(req, res) {
          return function (err, data) {
              if (err) {
                  return res.status(400).send(err);
              }
  
              res.header("Content-Type", "application/json");
              res.send(data);//JSON.stringify(data, null, 2));
          };
      }
  
      function render(req,res,file,data){
          res.render("master.ejs", { content: file, req: req, data: data});
  
      }
  
      app.get("/",(req,res,next)=&gt;{
          if(req.user){
          console.log("Path is "+appDir);
      // res.redirect("/views/welcome");
          res.redirect("/welcome");
          }
          else{
              console.log("Path is "+appDir);
          render(req, res,"login.ejs");}
      });
  
  
      app.use("/views", express.static(__dirname + '/views'))
  
      app.all("*", (req, res) =&gt; {
          res.status(404).send("Page was not found, sorry!");
      });
  
      var server = app.listen(process.env.PORT || 3000, process.env.IP || "0.0.0.0", () =&gt; {
          var address = server.address();
          console.log(`[${(new Date().toString()).substr(0, (new Date().toString()).indexOf(" ("))}] Server started on http://${address.address}:${address.port}`);
      });
  </code></pre>