my code in controller:
private function setCorsHeaders() {
$this->response = $this->response->cors($this->request)
->allowOrigin(['*'])
->allowMethods(['*'])
->allowHeaders(['Content-Type','X-CSRF-Token','Authorization'])
->exposeHeaders(['X-Total-Pages'])
->allowCredentials(['false'])
->maxAge(1024)
->build();
}
public function beforeRender(Event $event)
{
$this->setCorsHeaders();
}
public function beforeFilter(Event $event)
{
if($this->request->is('options')) {
$this->setCorsHeaders();
return $this->response;
}
}
Frontend: Angular 6