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.’ https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi?hl=en
only add this one for header,
let headers = new Headers();
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