Mungkin saya luruskan dulu pengertian CORS nya.
Sebenernya "CORS error" di browser terjadi karena browser Fetch API tunduk sama same-origin policy
.
Jadi defaultnya, JavaScript yang di serve di situs https://domain-a.com tidak dibolehkan browser melakukan http request ke https://domain-b.com/data.json.
Justru CORS (Cross-Origin-Resource-Sharing) itu mekanisme yang membolehkan kode JavaScript yang di browser yang di serve di https://domain-a.com untuk melakukan http request ke domain lain contohnya https://domain-b.com/data.json.
Implementasinya seperti apa?
Melalui http header Access-Control-Allow-Origin
dari server.
Kalau misalnya http header itu valuenya *, berarti CORS enabled, jadi javascript dari website apapun dibolehkan browser mengakses resources dari server tersebut.