Skip to content

Commit

Permalink
升级跨越配置设置
Browse files Browse the repository at this point in the history
  • Loading branch information
xxl4 committed Nov 11, 2023
1 parent acfb371 commit 22acbe6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions common/middleware/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ func Options(c *gin.Context) {
if c.Request.Method != "OPTIONS" {
c.Next()
} else {
c.Header("Access-Control-Allow-Origin", "*")
origin := c.Request.Header.Get("Origin")
c.Header("Access-Control-Allow-Origin", origin)
c.Header("Access-Control-Allow-Methods", "GET,POST,PUT,PATCH,DELETE,OPTIONS")
c.Header("Access-Control-Allow-Headers", "authorization, origin, content-type, accept")
c.Header("Allow", "HEAD,GET,POST,PUT,PATCH,DELETE,OPTIONS")
Expand All @@ -35,7 +36,8 @@ func Options(c *gin.Context) {
// Secure is a middleware function that appends security
// and resource access headers.
func Secure(c *gin.Context) {
c.Header("Access-Control-Allow-Origin", "*")
origin := c.Request.Header.Get("Origin")
c.Header("Access-Control-Allow-Origin", origin)
//c.Header("X-Frame-Options", "DENY")
c.Header("X-Content-Type-Options", "nosniff")
c.Header("X-XSS-Protection", "1; mode=block")
Expand Down

0 comments on commit 22acbe6

Please sign in to comment.