Hi,
i have a server with a normal domain and codeigniter 3.
To test a new project based on angular i would to do a query on DB server between Codeigniter.
Particularly i have a controller with all function that i need in my ajax call from my local machine.
When i do ajax call browser return in console this error:
Access to XMLHttpRequest at 'https://xxxxx.it/xxxx' from origin 'http://localhost:4200' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I have tried to add in my controller under parent:__constructor this headers:
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
if ( "OPTIONS" === $_SERVER['REQUEST_METHOD'] ) {
die();
}
But unfortunatly not work.
Then i have insert in my htaccess this:
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
But not work.
Some one can help me to enable CORS on my codeigniter3 ?
Thanks for help