Handle CORS correctly

CORS or Cross-origin resource sharing is a way to get around the "access-control-allow-origin" error safely.