Hey there I have added this to my routes.php
$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-Credentials', 'true')
->withHeader('Access-Control-Allow-Headers', 'X-Requested-With, Content-Type, Accept, Origin, Authorization, token')
->withHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
});
And my API does work for this request.
$http({
url:'http://myapiurl/public/login',
method:"POST",
data:{usuario:$scope.usuario, password:$scope.password}
})
but when i try to do this one,
$http({ method:"GET", url:"http://gear.aldroapi.aldro.test/public/informacion/"+$scope.id, headers:{'Authorization':'Bearer'+' '+ $cookies.get('jwtToken')} })
i get thisi error
Failed to load http://myapiurl/public/informacion/1376: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8000' is therefore not allowed access. The response had HTTP status code 500.
Do I need to add something else to my CORS headers?
EDIT: It has to do with the Authentication Bearer, because i added that url to passtrought the auth and works just fine.