call of javascript function to external url always blocked by cors

I put cors header on functions.php, allow cors on API, ensure https on both sides and allow cors on digital ocean – that hosts both wordpress and API