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


#21

Where do I add these codes? In which file?


#22

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
thanks


#23

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


#24

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


#25

only add this one for header,

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


#26

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’); ?


#27

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


#28

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