Although I set the API normally, when I connect, the following error appears and I can not access due to CORS.
Access to fetch at 'https://gitlab.ie.u-ryukyu.ac.jp/api/v4/projects/k198584%2Fanatofuznews' from origin 'https://ie.u-ryukyu.ac.jp' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
unsentRequest.js:41 GET https://gitlab.ie.u-ryukyu.ac.jp/api/v4/projects/k198584%2Fanatofuznews net::ERR_FAILED
Hey @AnaTofuZ,
The best fix would be to add the “Access-Control-Allow-Origin” header on the Gitlab side, to enable your origin (https://ie.u-ryukyu.ac.jp) to access it. We don’t know the answer to whether that’s possible but Gitlab support should!
If it turns out to not be possible to add that header, I’d suggest reviewing this article about proxying your requests through a Netlify Function:
Here is the function you’ll call from your page:
Let us know if this helps or if you have additional questions!
The idea is to have the function serve as a proxy (which sends correct CORS headers).
The CMS will send requests to the function which will proxy the requests to the self hosted GitLab instance.
Hopefully that makes things more clear.
Hi @AnaTofuZ – how did you go about resolving this? I have a similar set up as you (self hosted gitlab and domain) so if you can share what you did that would be much appreciated!