Check HTTP_ORIGIN using isset

This commit is contained in:
brantje 2017-01-19 13:58:34 +01:00
parent ff349ac6b0
commit f8c13471b7
No known key found for this signature in database
GPG key ID: 5FF1D117F918687F

View file

@ -17,9 +17,8 @@ class APIMiddleware extends Middleware {
public function afterController($controller, $methodName, Response $response) {
if($response instanceof JSONResponse){
$origin = $this->request->server['HTTP_ORIGIN'];
if($origin) {
$response->addHeader('Access-Control-Allow-Origin', $origin);
if(isset($this->request->server['HTTP_ORIGIN'])) {
$response->addHeader('Access-Control-Allow-Origin', $this->request->server['HTTP_ORIGIN']);
}
}
return parent::afterController($controller, $methodName, $response);