浏览代码

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
 			}