vue白名单/强制登录
// 白名单过滤
router.beforeEach((to, from, next) =>{
//不携带token的路由
var white = [ '/','/mi']
if (white.indexOf(to.path) >= 0){
next()
} else {
var token = localStorage.getItem('token')
if (token){
next()
} else {
router.push('/')
}
}
})
// 拦截器请求前
axios.interceptors.request.use(config=>{
console.log('请求前的拦截器:', config)
//如果有token则携带
var token = localStorage.getItem('token')
if (token){
config.headers['token'] = token
}
return config
})
改变flask端口号
if __name__=="__main__":
app.run(host='127.0.0.1',
port=8000,
debug=True)
![请添加图片描述](https://i-blog.csdnimg.cn/blog_migrate/ba17d7a44073832afc011fbffc495374.png)