I’m a new ionic developer. I use de last version of ionic and create a blank project.
I created a new provider for requests API.
browser requests are working but in ios not working.
import { Http } from ‘@angular/http’;
export class ApiSocialLemonProvider {
private apiUrl:string;
private headers:any = new Headers({
‘Access-Control-Allow-Origin’: ‘*’,
‘Access-Control-Allow-Methods’: ‘GET, POST, OPTIONS, PUT, PATCH, DELETE’,
‘Access-Control-Allow-Headers’: ‘X-Requested-With,content-type’,
‘Access-Control-Allow-Credentials’: true
});
constructor(public http: Http, private platform: Platform) {
//check platform web and using proxy //console.log(this.platform.platforms()); //console.log(this.platform.is(‘core’));
What I found is that you should set the HTTP server to have the right response to the CORS OPTIONS preflight request. The key point is that the Access-Control-Allow-Headers can not be “*” and should include any custom headers used in your app. Below is my setting that works:
Thank you so much @beck24. I was struggling from last 4 day to get the right solution for the same problem. Your solution worked like a charm. Thanks again.