Chrome is preflighting the request to look for CORS headers. If the request is acceptable, it will then send the real request. If you're doing this cross-domain, you will simply have to deal with it or else find a way to make the request non-cross-domain.
if($this->request->is('options')) { // @link: https://stackoverflow.com/a/21783145/5504312
 return $this->response
  ->withHeader('Access-Control-Allow-Origin', '*')
  ->withHeader('Access-Control-Allow-Headers', '*')
  ->withHeader('Access-Control-Allow-Credentials', 'true')
  ->withHeader('Access-Control-Allow-Methods','OPTIONS, GET, POST');
} 
?>

Nenhum comentário:
Postar um comentário