I have an Api rest made with Laravel protected with JWT. The login works correctly, however, when using the Bearer Token returned by the login I get the error:
Access to XMLHttpRequest at 'http: //api-laravel3.test/api/movies' from origin 'http: // localhost: 8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
Postman access via Bearer Token works correctly. The problem occurs with Axios
var token = localStorage.getItem('user-token');
axios.get('http://api-laravel3.test/api/movies', {
headers:{
'Content-Type': 'application/json',
'Authorization': 'Bearer '+token,
}
}).then(function (response) {
console.log('OK ' + response.status);
return response.data
})
.catch(function (error) {
console.log('Error: ' + error.response );
//return Promise.reject(error);
});