Hi All,
I’m trying to use Ionic to login to my backend system which is built on Laravel.
This is what I have for the login.ts
file:
export class LoginPage {
apiUrl = "https://mydomain.com";
private myData: any;
constructor(public navCtrl: NavController, public navParams: NavParams, public http: Http) {
}
doLogin (formData) {
this.myData = formData.value;
let body = JSON.stringify({
email: formData.value.email,
password: formData.value.password
});
console.log(body);
let headers = new Headers({
"Accept": "application/json",
"Authorization": "Bearer: Pwjxo8aSrRGrdFutYSGqbbBy9Qtn5wyX",
});
this.http.post(this.apiUrl + '/api/authenticate', JSON.stringify(body), {
headers: headers
}).subscribe(function(data) {
console.log('received response');
});
}
}
But I’m having an issue with CORS , although on the Laravel side CORS is enabled.
Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header contains multiple values '*, http://localhost:8100', but only one is allowed. Origin 'http://localhost:8100' is therefore not allowed access.
Does anyone have any ideas?