https://www.youtube.com/watch?v=8GhfHZlEaEo&list=PLT9miexWCpPW6Z_OXNv2d78cqCrZaPrVG&index=41 In case Web Server throws CORS errors when trying to access API. We add a filter that adds header with CORS info to define which kind of HTTP are allowed from foreign source. Create CorsFilter.php ```bash php spark make:filter Cors --suffix ``` Add to before method: ```php public function before(RequestInterface $request, $arguments=null) { header("Access-Control-Allow-Origin: *"); header("Access-Control-Allow-Headers: Authorization, Content-Type, Accept, API-KEY"); header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE, PATCH"); } ``` Add in app/Config/Filters.php: ![[Pasted image 20241202084231.png]] ![[Pasted image 20241202084303.png]]