I am using codeigniter as backend and ANGULAR 4 As a REST Based Frontend Client.The problem is every request is sent twice ONE is using OPTION and other is using GET or POST.
Screenshot of Console Network tab.
https://i.stack.imgur.com/q3GqL.jpg
I got this in console for each of the every other API request, Once I have First successfull login api. How to stop the extra OPTION request because my server is not coded to handle this request. I know it has to do something with preflight request option and I am not sure how to solve it.
Update
due to setting the below custom header, I am getting triggred with additional OPTIONS request.
this.headers.append('sessionname','7datfaaj6slo7p7htubtutn970l20lfd');
Now , I have enabled the CORS on serverside and put this condition to give correct output for OPTIONS request.
$method = $_SERVER['REQUEST_METHOD']; if($method == "OPTIONS") { die(); }
So it is working fine, But now my question is it perfect way to handel this annoying OPTIONS request?