title: Vue or Axios don't store session cookie
body: <p>I face a problem but i don't know where it be and why.
  I have a backend API based on express4(nodejs) We have implemented Auth with passport.</p>
  
  <p>When i use postman, i log with post on /login. it store a session cookie and all route is now accesible since the cookie is not expired.</p>
  
  <p>But with my frontend based on VueJS. I use Axios for doing the Request. The request seems to be good. but any cookie is stored so the browser do a loopback on he login page.</p>
  
  <p>I have tried without the auth check or not it the same. But on postman it work.</p>
  
  <p>the main.js for Vue:</p>
  
  <pre><code>import Vue from 'vue'
  import VueRouter from 'vue-router'
  import Axios from 'axios'
  Vue.use(VueRouter)
  
  import auth from './utils/auth'
  
  import App from './components/App.vue'
  
  import Login from './components/Login.vue'
  import Home from './components/Containers.vue'
  
  require('font-awesome-loader');
  
  function requireAuth (to, from, next) {
    if (!auth.checkAuth()) {
      next({
        path: '/login',
        query: { redirect: to.fullPath }
      })
    } else {
      next()
    }
  }
  
  const router = new VueRouter({
    mode: 'history',
    routes: [
      { path: '/', name: 'containers', component: Home, beforeEnter: requireAuth },
      { path: '/login', component: Login },
      { path: '/logout',
        beforeEnter (to, from, next) {
          auth.logout()
          next('/')
        }}
    ]
  })
  
  new Vue({
    el: '#app',
    router,
    render: h =&gt; h(App)
  })
  </code></pre>
  
  <p>And the auth.js (where the request is done)</p>
  
  <pre><code>import axios from 'axios'
  import { API_URL } from '../config/app'
  
  export default {
  
    user: {
      authenticated: false
    },
  
    login (email, pass, cb) {
      LoginRequest(email, pass, (res) =&gt; {
        this.user.authenticated = res.authenticated
        if (this.user.authenticated) {
          console.log('ok')
          if (cb) cb(true)
        } else {
          console.log('pasok')
          if (cb) cb(false)
        }
      })
    },
  
    checkAuth () {
      if (getAuth()) {
        this.authenticated = true
      } else {
        this.authenticated = false
      }
    },
  
    logout (cb) {
      this.user.authenticated = false
      if (cb) cb()
    }
  }
  
  function LoginRequest (email, pass, cb) {
    axios.post(API_URL + '/api/login', {
      email: email,
      password: pass
    }).then(response =&gt; {
      if (response.status === 200) {
        cb({ authenticated: true })
      } else {
        cb({ authenticated: false })
      }
    }, response =&gt; {
      cb({ authenticated: false })
    })
  }
  
  function getAuth (cb) {
    axios.get(API_URL + '/me').then(response =&gt; {
      return true
    }, response =&gt; {
      return false
    })
  }
  </code></pre>
  
  <p>EDIT :
  my cors use on the backend : </p>
  
  <pre><code> // allow CORS:
          app.use(function (req, res, next) {
            res.header("Access-Control-Allow-Origin", "*");
            res.header("Access-Control-Allow-Methods", "GET,HEAD,OPTIONS,POST,PUT$
            res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With,$
            next();
          });
  </code></pre>
  
  <p>Thank !</p>