CORS Issue when calling the subdomain from main domain and vice versa

Hi,
I have a sub domain subdomainA
and a main domain mainDomain both points to the same server and same source.

I am facing the following issue when calling the api of main domain from the sub domain url as below:

Access to XMLHttpRequest at ‘MainDomain’ from origin ‘subdomainA’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: It does not have HTTP ok status.

I have tried all the suggestions so far but could not fix the issue.

Anybody please guide me to fix this error ?

Can you share your domain here? You need to make sure that your API server is set up to use CORS.