Answer the question
In order to leave comments, you need to log in
Why VueJs&Laravel5 authorization fails?
Hello, there was such a problem that when authorizing through laravel passport, a 401 error is returned to me, but if I try to authorize again, then everything is OK
. I send a request with vuejs using axios, there is a token, it is transmitted correctly. but I can’t understand why this happens
UPD1 a little config.js code
const config = function(cook) {
return {
baseURL: API_URL,
headers: {
Accept: 'application/json',
Authorization: `Bearer ${cook}`
}
}
}
const getEnrollList = (role) => {
let url = ''
url = role == 'master' ? '/master/getEnrollList' : '/client/getEnrollList'
return API.get(url, {
params: {
hash: Cookie.get('salon')
},
headers: {
Authorization: `Bearer ${Cookie.get('token')}`
}
}).catch( (response, error) => {
window.location.href = '/'
})
}
Route::group(['middleware' => ['web','auth:api']], function() {
Route::get('getEnrollList', 'Client\[email protected]');
// Роутер для клиента
Route::group(['prefix' => 'client', 'middleware' => 'client'], function () {
Route::get('getEnrollList', 'Client\[email protected]');
});
// Роутер для мастера
Route::group(['prefix' => 'master', 'middleware' => 'master'], function () {
Route::get('getEnrollList', 'Master\[email protected]');
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question