I'm using golang gin and I got this error
I know this is a CORS error and I fixed it in NodeJS but this time I'm working with golang and hence not able to fix it.
I got around this package https://github.com/gin-contrib/cors
and modified my code
r := gin.Default()
r.Use(cors.New(cors.Config{
AllowOrigins: []string{"http://localhost:5173"},
AllowMethods: []string{"PUT", "PATCH", "POST"},
AllowHeaders: []string{"Origin"},
ExposeHeaders: []string{"Content-Length", "Content-Type"},
AllowFiles: true,
AllowCredentials: true,
AllowOriginFunc: func(origin string) bool {
return origin == "http://localhost:5173"
},
}))
`
But the thing is that this error still coming up.