I am using AngularJS as front-end and Laravel as back-end for handling API requests.
Also, Laravel constitute the administration panel for the website.
In order to overcome the CORS related challenges, I've added the following code in routes.php of Laravel:
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: Origin, Content-Type');
header('Access-Control-Allow-Methods', 'GET,POST, OPTIONS');
header('Access-Control-Allow-Credentials', 'true');
header('Access-Control-Allow-Headers', 'accept, content-type, x-xsrf-token, x-csrf-token');
But when we load administration panel it shows internal server error (GoDaddy server).
If we remove this the administration panel works fine, but the AngularJS part faces problem.
The API requests are blocked by the server.
What am I doing wrong and how can I resolve this issue?
header()edits?header. Have a look at en.vedovelli.com.br/2015/web-development/…