Can't serve api on web browser

Viewed 69

Below is the code for making a api server with go gin. But it has some troubles that when I call with postman a GET api work. But when I call by pasting the url to google chrome browser it failed

router := gin.Default()

config := cors.DefaultConfig()
config.AllowAllOrigins = true

router.Use(cors.New(config))

router.Run("4000")

1 Answers

Use router.Run(":4000")

Note: If you don't mention any address and just colon (:) followed by port, it will listen on TCP port 4000 on all available unicast and anycast IP addresses of the local system.

Related