Commit 894ad2700fcb3a68136d6ac08b0d7a3457282770
1 parent
6d9e49a2
Exists in
master
and in
1 other branch
Habilitando Cors
Showing
1 changed file
with
14 additions
and
0 deletions
Show diff stats
controlador_ws.php
... | ... | @@ -40,6 +40,20 @@ $config = array( |
40 | 40 | ); |
41 | 41 | |
42 | 42 | $app = new \Slim\App($config); |
43 | + | |
44 | +//Enable CORS | |
45 | +$app->options('/{routes:.+}', function ($request, $response, $args) { | |
46 | + return $response; | |
47 | +}); | |
48 | + | |
49 | +$app->add(function ($req, $res, $next) { | |
50 | + $response = $next($req, $res); | |
51 | + return $response | |
52 | + ->withHeader('Access-Control-Allow-Origin', '*') | |
53 | + ->withHeader('Access-Control-Allow-Headers', 'X-Requested-With, Content-Type, Accept, Origin, Authorization, token') | |
54 | + ->withHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS'); | |
55 | +}); | |
56 | + | |
43 | 57 | /** |
44 | 58 | * Grupo para a versao v1 de servicos REST |
45 | 59 | */ | ... | ... |