The server decides
CORS is a server policy, not a browser one. The server says which origins may read it via Access-Control-Allow-Origin. If the header is absent, the browser refuses. So the fix is always on the server, never in the page.
Preflight before custom
A request with non-simple headers or methods triggers an OPTIONS preflight. The server must allow those headers or the real call is blocked. A confusing CORS error is often a preflight that said no to one header name.