ソースを参照

return 204 for cross-origin OPTIONS

Roy Han 9 ヶ月 前
コミット
781585d9bd
1 ファイル変更5 行追加0 行削除
  1. 5 0
      server/routes.go

+ 5 - 0
server/routes.go

@@ -1043,6 +1043,11 @@ func allowedHostsMiddleware(addr net.Addr) gin.HandlerFunc {
 
 		if addr, err := netip.ParseAddr(host); err == nil {
 			if addr.IsLoopback() || addr.IsPrivate() || addr.IsUnspecified() || isLocalIP(addr) {
+				if c.Request.Method == http.MethodOptions {
+					c.AbortWithStatus(http.StatusNoContent)
+					return
+				}
+
 				c.Next()
 				return
 			}