【发布时间】:2020-01-21 05:35:46
【问题描述】:
在 nuxt axios mudule 中未设置 baseURL,我无法使用 nxut/auth 模块进行身份验证。
这是 nuxt.config.js:
auth: {
strategies: {
local: {
endpoints: {
login: {url: 'auth/login', method: 'post', propertyName: 'data.access_token'},
user: {url: 'user', method: 'get', propertyName: 'data'},
logout: {url: 'auth/logout', method: 'post'}
},
tokenRequired: true,
tokenType: 'Bearer',
},
redirect: {
home: '/',
login: '/login',
logout: '/logout'
}
}
},
axios: {
baseURL: "api.dvl/api/v1/"
},
一切正常,但如果我提出请求,它会请求http://localhost:3000/auth/login
怎么了?
我的登录页面:
data() {
return {
title: process.env.title.fa,
form: {
email: null,
password: null,
remember: false
}
}
},
methods: {
async login() {
await this.$axios.$post('/login', this.form)
this.$auth.login({ data: this.form })
}
}
【问题讨论】:
标签: vue.js authentication axios nuxt.js