Skip to content

Commit

Permalink
允许跨域访问
Browse files Browse the repository at this point in the history
  • Loading branch information
tddlerya committed Dec 14, 2018
1 parent 79aa687 commit 96595eb
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strconv"
"strings"

"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
"github.com/toddlerya/fakerfactory/faker"
)
Expand All @@ -15,6 +16,7 @@ var Conn *sql.DB = faker.CreateConn(dbPath) // 不应该在这里建立连接,

func StartServer() {
router := gin.Default()
router.Use(cors.Default()) // 允许任何服务ajax跨域调用
v1 := router.Group("api/v1")
{
v1.GET("/fakerfactory", GetFaker)
Expand Down

0 comments on commit 96595eb

Please sign in to comment.