Move code for CORS check