From 9fc3de9bd3ccaf8476f462a7fb3f247a97ca2837 Mon Sep 17 00:00:00 2001 From: Ruben Date: Thu, 3 Nov 2016 03:43:08 +0100 Subject: [PATCH] cors fix --- src/Api/InterfaceControllerProvider.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/Api/InterfaceControllerProvider.php b/src/Api/InterfaceControllerProvider.php index 4916b44..abea2ea 100644 --- a/src/Api/InterfaceControllerProvider.php +++ b/src/Api/InterfaceControllerProvider.php @@ -27,6 +27,17 @@ class InterfaceControllerProvider implements ControllerProviderInterface // /interface/game/last $controllers->get('/games/last', function (Application $app) { + + $http_origin = $_SERVER['HTTP_ORIGIN']; + if ($http_origin == "https://emotionhero.com" || $http_origin == "http://emotionhero.com") + { + header("Access-Control-Allow-Origin: $http_origin"); + // header("Access-Control-Allow-Origin: https://emotionhero.com"); + header("Access-Control-Allow-Methods: POST, GET, OPTIONS"); + header("Access-Control-Allow-Headers: X-PINGOTHER"); + header("Access-Control-Max-Age: 1728000"); + } + $gameRepo = $this->_eh->getEm()->getRepository(\EmotionHero\Models\Game::class); /* @var $hitRepo EmotionHero\Models\HitRepository */ $hitRepo = $this->_eh->getEm()->getRepository(\EmotionHero\Models\Hit::class); @@ -106,6 +117,17 @@ class InterfaceControllerProvider implements ControllerProviderInterface // /interface/images $controllers->get('/images', function (Application $app) { + + $http_origin = $_SERVER['HTTP_ORIGIN']; + if ($http_origin == "https://emotionhero.com" || $http_origin == "http://emotionhero.com") + { + header("Access-Control-Allow-Origin: $http_origin"); + // header("Access-Control-Allow-Origin: https://emotionhero.com"); + header("Access-Control-Allow-Methods: POST, GET, OPTIONS"); + header("Access-Control-Allow-Headers: X-PINGOTHER"); + header("Access-Control-Max-Age: 1728000"); + } + $getEmoBlocks = function($emotion, $feature, $steps = 6) { $hitRepo = $this->_eh->getEm()->getRepository(Models\Hit::class); $blocks = [];