diff --git a/Classes/Http/HttpOptionsComponent.php b/Classes/Http/HttpOptionsComponent.php new file mode 100644 index 0000000..9ed1e82 --- /dev/null +++ b/Classes/Http/HttpOptionsComponent.php @@ -0,0 +1,39 @@ +getHttpRequest(); + // no OPTIONS request => skip + if ($httpRequest->getMethod() !== 'OPTIONS') { + return; + } + // no matching graphQL endpoint configured => skip + if (!isset($this->endpoints[$httpRequest->getRelativePath()])) { + return; + } + $httpResponse = $componentContext->getHttpResponse(); + $httpResponse->setHeader('Allow', 'GET, POST'); + $componentContext->setParameter(ComponentChain::class, 'cancel', true); + } +} diff --git a/Configuration/Settings.yaml b/Configuration/Settings.yaml index 679f6f4..6964911 100644 --- a/Configuration/Settings.yaml +++ b/Configuration/Settings.yaml @@ -1,3 +1,12 @@ +TYPO3: + Flow: + http: + chain: + 'process': + chain: + 'graphQLOptions': + position: 'before routing' + component: 'Wwwision\GraphQL\Http\HttpOptionsComponent' Wwwision: GraphQL: endpoints: []