title: Making redirects after an axios post request with express
body: <p>I'm having trouble getting redirects to work after accepting a post request from Axios. I do know that the request is being sent and that it at least gets some response from the '/' route, because my console logs "index", "user verified" which is what should happen when someone makes a get request to '/'. The problem is that the page doesn't load. I've even seen in the networking tab on google chrome that index.js is loaded but the page will not change no matter what I've tried! Is there any reason for this? </p>
  
  <p>Other redirects that I've made do seem to work. For example, the index page will reroute to /login if the user is not logged in. This seems to only be an issue with the post request and I have tested it with and without passport authentication (obviously changed that you would need to be logged in to redirect) and it's the same result. So I do not think passport is causing the issue.</p>
  
  <p>You can refer to package.json below to see what I am using </p>
  
  <p>axios code:</p>
  
  <pre><code>axios.post('/login', {username: username, password: password})
          /*.then(response =&gt; res.redirect('/'))*/
          .then(function (response) {
              console.log(response);
          })
          .catch(function(error) {
              console.log(error);
          })
  </code></pre>
  
  <p>express side: I have console logs to alert myself during testing</p>
  
  <pre><code> server.get('/', (req,res) =&gt;{
      console.log("Index");
    if (req.user){
         console.log("user verified");
          res.redirect('/');
          app.render(req,res, '/',req.query);
    } else {
        console.log("user not logged in");
        res.redirect('/login');
    }
  })
  
  server.post('/login', passport.authenticate('local'), (req, res, next) =&gt; {
      if (req.user) {
          console.log("Logging in");
          res.redirect('/');
    } else {
          console.log("Passwrod Incorrect");
          return res.redirect('/login');
    }
  })
  </code></pre>
  
  <p>package.json</p>
  
  <pre><code>{
    "name": "layout-component",
    "version": "1.0.0",
    "scripts": {
      "dev": "node ./server.js",
      "build": "next build",
      "start": "NODE_ENV=production node ./server.js"
    },
    "dependencies": {
      "@zeit/next-css": "^0.1.5",
      "axios": "^0.18.0",
      "bcryptjs": "^2.4.3",
      "body-parser": "^1.18.2",
      "connect-flash": "^0.1.1",
      "connect-mongo": "^2.0.1",
      "cookie-parser": "^1.4.3",
      "express": "^4.16.3",
      "express-session": "^1.15.6",
      "express-validator": "^5.1.0",
      "file-loader": "^1.1.11",
      "hoist-non-react-statics": "^2.5.0",
      "jsonwebtoken": "^8.2.0",
      "mongodb": "^3.0.5",
      "mongoose": "^5.0.12",
      "next": "^5.1.0",
      "passport": "^0.4.0",
      "passport-local": "^1.0.0",
      "prop-types": "^15.6.1",
      "react": "^16.3.0",
      "react-dom": "^16.3.0",
      "semantic-ui-css": "^2.3.1",
      "semantic-ui-react": "^0.79.0",
      "url-loader": "^1.0.1"
    },
    "license": "ISC"
  }
  </code></pre>