I'm developing a webapp and I'm using Angunlar 2 as my frontend framework and CodeIgniter 3 as my backend framework. I use Angular-CLI, so my Angular app runs on port 4200, while my "server-side" works on port 80.
So, when I try to do a post request from Angular to PHP, I'm making a cross-domain request, because of the different ports. I checked it in the Network tabs of Chrome, I see the two request done (one for options and one for the post itself).
The problem that I have is that I can't figure out to receive the post body (I have changed the Content-Lenght to in my header and is always on runtime).
The headers I have configured are:
header('Content-Type: text/plain; charset=utf-8');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
header('Access-Control-Allow-Headers: Content-Type');
The question is: is there a way to avoid the cross-domain here? Naturally, I have tryed to start the serve in port 80, but it is busy. And if there is not a way to avoid the cross-domain, could someone please give me and idea of how to continue working with this?
Thanks