Skip to content

Commit bafe18f

Browse files
author
汪先森
committed
cors.go: fix部分浏览器不支持*的格式
1 parent 3fbb2ab commit bafe18f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

server/middleware/cors.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import (
99
func Cors() gin.HandlerFunc {
1010
return func(c *gin.Context) {
1111
method := c.Request.Method
12-
c.Header("Access-Control-Allow-Origin", "*")
12+
origin := c.Request.Header.Get("Origin")
13+
c.Header("Access-Control-Allow-Origin", origin)
1314
c.Header("Access-Control-Allow-Headers", "Content-Type,AccessToken,X-CSRF-Token, Authorization, Token,X-Token,X-User-Id\"")
1415
c.Header("Access-Control-Allow-Methods", "POST, GET, OPTIONS,DELETE,PUT")
1516
c.Header("Access-Control-Expose-Headers", "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers, Content-Type")

0 commit comments

Comments
 (0)