Skip to content

Commit

Permalink
set up cors
Browse files Browse the repository at this point in the history
  • Loading branch information
sdklos committed Jan 18, 2022
1 parent 0eabf9d commit 6b37eb7
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions public/index.php
Expand Up @@ -38,4 +38,17 @@
};
});

$app->add(function ($req, $res, $next) {
$response = $next($req, $res);
return $response
->withHeader('Access-Control-Allow-Origin', '*')
->withHeader('Access-Control-Allow-Headers', 'X-Requested-With, Content-Type, Accept, Origin, Authorization')
->withHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, PATCH, OPTIONS');
});

$app->map(['GET', 'POST', 'PUT', 'DELETE', 'PATCH'], '/{routes:.+}', function($req, $res) {
$handler = $this->notFoundHandler; // handle using the default Slim page not found handler
return $handler($req, $res);
});

$app->run();

0 comments on commit 6b37eb7

Please sign in to comment.