Reputation: 87
So my problem is: I Have Lumen server on subdomain api.domain.com After sending ajax request from domain.com to api.domain.com:
$.ajax({
url: 'https://api.domain.com/login',
type: 'post',
headers: {
'Authorization': 'someJWTTOKEN'
'Content-Type': 'application/json'
},
data: {},
dataType: 'json',
success: function(result) {
console.log('result');
console.log(result);
},
error: function(error) {
console.log(error);
}
});
But when I remove Header from ajax request, everything works fine.
This works great:
$.ajax({
url: 'https://api.domain.com/login',
type: 'post',
headers: {
},
data: {},
dataType: 'json',
success: function(result) {
console.log('result');
console.log(result);
},
error: function(error) {
console.log(error);
}
});
Upvotes: 0
Views: 767
Reputation: 574
I had this problem connecting my React app to my Lumen API but solved it by using this PHP Package. In the README they explain how to configure the package with Lumen. Legit took me like 2 minutes.
Upvotes: 1