1//his code in the file public/index.php work perfectly.
2
3header('Access-Control-Allow-Origin: *');
4header("Access-Control-Allow-Headers: X-API-KEY, Origin, X-Requested-With, Content-Type, Accept, Access-Control-Request-Method");
5header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE");
6header("Allow: GET, POST, OPTIONS, PUT, DELETE");
7$method = $_SERVER['REQUEST_METHOD'];
8if ($method == "OPTIONS") {
9 die();
10}
11
12https://stackoverflow.com/a/60642286/7610978