[Vuejs]-Authorization using Vue.js and Express,js

0👍

So i add a header in Express like that

const allowCrossDomain = function (req, res, next) {
  res.header('Access-Control-Allow-Origin', 'http://localhost:8080');
  res.header('Access-Control-Allow-Methods', '*');
  res.header('Access-Control-Allow-Headers', 'origin, content-type, accept');
  res.header('Access-Control-Allow-Credentials', true);
  next();
}
app.use(allowCrossDomain);

then
check authorization

axios.get('url',{withCredentials:true}) 

and login

axios.post('login',{withCredentials:true}) 

like that

Leave a comment