Updated code to use CORS requests.