-
Notifications
You must be signed in to change notification settings - Fork 8.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
i keep getting cors error #4144
Comments
Without a complete and minimal reproducible code example provided, it’s difficult to identify the exact cause of the issue. However, unless there’s a specific reason not to, I recommend using gin-contrib/cors. |
try this code
|
This is example from my cors middleware. I'm using vuejs for frontend. Maybe you could try this. cors_config := cors.Config{
AllowMethods: []string{"GET", "POST", "PUT", "DELETE"},
AllowHeaders: []string{"Origin", "Content-Type", "Authorization"},
AllowCredentials: true,
AllowOrigins: []string{"http://localhost:3000"},
}
r := gin.Default()
r.Use(cors.New(cors_config)) For the frontend part, I'm using axios so don't forget to include "withCredentials: true". Also don't forget to install cors package go get github.com/gin-contrib/cors |
so i have a project that use both nextjs and golang as its frontend and backend. I keep getting blocked from fetching my data because of CORS
this is my cors code on the backend :
i already specify the origin to my localhost domain but it wont work and i also have experimented in my frontend code to put no-cors but still no result. Please help me out
The text was updated successfully, but these errors were encountered: