Selaa lähdekoodia

return 204 for cross-origin OPTIONS

Roy Han 9 kuukautta sitten
vanhempi
commit
781585d9bd
1 muutettua tiedostoa jossa 5 lisäystä ja 0 poistoa
  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
 			}