I try this specific code but it keep on giving me error in
No 'Access-Control-Allow-Origin'
package main
import (
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
)
func main() {
router := gin.Default()
router.Use(cors.Default())
v1 := router.Group("/api/products")
{
v1.GET("/", ListOfProducts)
v1.POST("/post",AddProduct)
}
}
The error is
My frontend is written in Vue.js and running on localhost:8000
localhost and the server is running on localhost:9000
curl -H "Origin: http://localhost:8000" --verbose localhost:9000
? Does the headerAccess-Control-Allow-Origin: *
present? – AccadRebuilt URL to: localhost:9000/ * Trying ::1... * TCP_NODELAY set * Connected to localhost (::1) port 9000 (#0) > GET / HTTP/1.1 > Host: localhost:9000 > User-Agent: curl/7.54.0 > Accept: */* > Origin: http://localhost:8000 > < HTTP/1.1 404 Not Found < Access-Control-Allow-Origin: * < Content-Type: text/plain < Date: Wed, 13 Feb 2019 08:48:10 GMT < Content-Length: 18
– Fancier