Http post Request error *No access control origin * in ionic


Where do I add these codes? In which file?


You need to write that code in your page from you are sending api requests , if you send request for your home page of app , then you should write that code inn home.ts


simple solution but if we produce this and run it on a real device we will face problem again or not?


No, If you want to remove this kind of error from chrome console you can add google chrome ‘no access control origin plugin i.e.’


only add this one for header,

let headers = new Headers();
headers.append(‘Content-Type’, ‘multipart/form-data’);


My api is in PHP can i set in PHP the same instructions: headers.append(‘Access-Control-Allow-Origin’ , ‘*’); and headers.append(‘Access-Control-Allow-Methods’, ‘POST, GET, OPTIONS, PUT’); ?


How can i do this same step using ionic 1 and angularjs 1 ?


I getting this issue in my device.
What should I do