return 204 for cross-origin OPTIONS

This commit is contained in:
Roy Han 2024-07-10 12:52:34 -07:00 committed by royjhan
parent b84a54be05
commit 781585d9bd

View File

@ -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
}