0
votes

hey im new to ionic 3 i prepared a form of contact for my application where the server (php) has to send an email after the filling of the form by the user . in the server i use the function mail to send email by the server it works find and it sends email even with the appearence of error of No 'Access-Control-Allow-Origin' header
I already added the two headers in my php scripts

header("Access-Control-Allow-Origin: *"); header('Content-Type: text/html; charset=utf-8'); enter image description here

1

1 Answers

1
votes

This is not a problem of your ionic app. The server you try to access via api call doens't support CORS. Hopefully this article helps you to solve your problem.

https://blog.ionicframework.com/handling-cors-issues-in-ionic/

There is a tutorial or solution to solve your problem.

Here is the important part for you

Dealing with CORS in Ionic CORS is only an issue when we are running or testing our app when running ionic serve or ionic run -l.

There are two ways to solve the issue: The first, and easier, solution is to just allow all origins from your API endpoint. However, we can’t always control the endpoint we are accessing. What we need, then, is a request that does not specify an origin.

We can do this by using a proxy server. Let’s look how the Ionic CLI provides an easily configurable proxy server.