I am using the @nuxtjs/auth'
module of Nuxt.js for login authentication, but when I use the loginWith
method, I get an error because it jumps to an unspecified URL instead of the URL set in config. I need to know how and why this is happening.
URL set in config
'/api/v1/auth/sign_in'
The actual URL being sent
/api/auth/login
config
// Axios module configuration: https://go.nuxtjs.dev/config-axios
axios: {
baseURL: 'http:localhost:3000'
},
auth: {
redirect: {
login: '/user/login',
logout: '/user/login',
callback: false,
home: '/'
},
strategines: {
local: {
endpoints: {
login: { url: '/api/v1/auth/sign_in', method: 'post', propertyName: 'token' },
logout: { url: '/api/v1/auth/sign_out', method: 'delete' },
user: { url: '/api/v1/auth/user', method: 'get' }
}
}
}
},
components
import logoImg from '~/assets/images/login_logo.png'
export default {
data () {
return {
logoImg,
userInfo: {
email: '',
password: ''
}
}
},
methods: {
async login () {
await this.$auth.loginWith('local', {
data: {
email: this.userInfo.email,
password: this.userInfo.password
}
})
.then(
(response) => {
localStorage.setItem('access-token', response.headers['access-token'])
localStorage.setItem('client', response.headers.client)
localStorage.setItem('uid', response.headers.uid)
localStorage.setItem('token-type', response.headers['token-type'])
return response
},
(error) => {
return error
}
)
}
}
}
OST http://localhost:3000/api/auth/login 404 (Not Found)
You have typos in your config.
strategines
-> strategies
http:localhost:3000
-> http://localhost:3000