Bläddra i källkod

处理跨域问题

Zhou Xiaoning 5 år sedan
förälder
incheckning
c22fd23211
1 ändrade filer med 2 tillägg och 1 borttagningar
  1. 2 1
      routers/router.go

+ 2 - 1
routers/router.go

@@ -14,6 +14,7 @@ import (
 	"mtp2_if/controllers/wrtrade"
 	"mtp2_if/logger"
 	"mtp2_if/token"
+	"net/http"
 	"time"
 
 	"github.com/gin-gonic/gin"
@@ -188,7 +189,7 @@ func CORSMiddleware() gin.HandlerFunc {
 		c.Writer.Header().Set("Access-Control-Allow-Methods", "POST, OPTIONS, GET, PUT")
 		c.Writer.Header().Set("Access-Control-Expose-Headers", "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers, Content-Type, X-session-Token")
 		if c.Request.Method == "OPTIONS" {
-			// c.AbortWithStatus(http.StatusNoContent)
+			c.AbortWithStatus(http.StatusNoContent)
 			return
 		}