Contexto, cree una api restful con codeigniter 3, la cual me permite consumirla desde postman y con ajax de jq en localhost o desde otro dominio de la web. Cuando quiero consumirla desde una aplicación creada en note que utiliza axios me manda el siguiente error:
Access to XMLHttpRequest at 'ruta api' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
const repuesta = await clienteAxios.get("link_api", {
headers: {
'Authorization': `eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6Inl1cmk4OSIsImNhZHVjaWRhZCI6MTU4MjMwMjkxMX0.Aa7cKdNFx0whL2ePgp3eqa32SIw4LWfezdtcxnFdw6I`
}
})
configuración de codeigniter:
$config['check_cors'] = TRUE;
$config['allowed_cors_headers'] = [
'Origin',
'X-Requested-With',
'Content-Type',
'Accept',
'Access-Control-Request-Method'
];
$config['allowed_cors_methods'] = [
'GET',
'POST',
'OPTIONS',
'PUT',
'PATCH',
'DELETE'
];
$config['allow_any_cors_domain'] = TRUE;
$config['allowed_cors_origins'] = [];
$config['forced_cors_headers'] = [];