Added CORS handling for 404 and 500 errors on API2 and API3