From 894ad2700fcb3a68136d6ac08b0d7a3457282770 Mon Sep 17 00:00:00 2001 From: André Manoel Date: Wed, 10 May 2017 17:12:13 -0300 Subject: [PATCH] Habilitando Cors --- controlador_ws.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+), 0 deletions(-) diff --git a/controlador_ws.php b/controlador_ws.php index 2c58e67..abeee2a 100644 --- a/controlador_ws.php +++ b/controlador_ws.php @@ -40,6 +40,20 @@ $config = array( ); $app = new \Slim\App($config); + +//Enable CORS +$app->options('/{routes:.+}', function ($request, $response, $args) { + return $response; +}); + +$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, token') + ->withHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS'); +}); + /** * Grupo para a versao v1 de servicos REST */ -- libgit2 0.21.2