I am new with GraphQL. I need to make an API with PHP and GraphQL. I followed this tutorial: https://medium.com/swlh/setting-up-graphql-with-php-9baba3f21501
everything was OK, but when opening the URL, I got this error:
{
"statusCode": 405,
"error": {
"type": "NOT_ALLOWED",
"description": "Method not allowed. Must be one of: OPTIONS"
}
}
I added this to the index page :
header('Access-Control-Allow-Origin', '*');
header('Access-Control-Allow-Headers', 'content-type');
header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
but the problem wasn't resolved. Maybe something is missing here:
return function (App $app) {
$app->options('/{routes:.*}', function (Request $request, Response $response) {
// CORS Pre-Flight OPTIONS Request Handler
return $response;
});