Open SoniSuciadi opened 3 months ago
Are you sure your react app running at 3000
, and your gin server running at 6969
?
$ curl -i http://localhost:6969/v1/help-center/faq
HTTP/1.1 307 Temporary Redirect
Location: /v1/help-center/faq
Content-Length: 0
Date: Wed, 31 Jul 2024 12:34:56 GMT
In the React application, I get the following error in the console:
Access to XMLHttpRequest at 'http://localhost:6969/v1/help-center/faq' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
POST http://localhost:6969/v1/help-center/faq net::ERR_FAILED 307 (Temporary Redirect)
![Tangkapan Layar 2024-07-31 pukul 22 38 11](https://github.com/user-attachments/assets/dadf7b85-a340-47d4-a794-853c785971c9)
<img width="329" alt="Tangkapan Layar 2024-07-31 pukul 22 38 34" src="https://github.com/user-attachments/assets/3acd327e-cbb5-43df-b630-384c9d4dfeb0">
from this log, I guss your react app is running at 6969
Description
I am experiencing a CORS issue when trying to access an endpoint from a React application running at
http://localhost:3000
to a Gin server running athttp://localhost:6969
. Even though I have added CORS middleware usinggin-contrib/cors
, I still get the errorNo 'Access-Control-Allow-Origin' header is present on the requested resource.
How to reproduce
Here is the code used in my Go application: