diff --git a/spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/route/Route.java b/spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/route/Route.java index 9193e0e3..7cebb1fc 100644 --- a/spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/route/Route.java +++ b/spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/route/Route.java @@ -187,9 +187,11 @@ public class Route implements Ordered { this.uri = uri; String scheme = this.uri.getScheme(); Assert.hasText(scheme, "The parameter [" + this.uri + "] format is incorrect, scheme can not be empty"); - if (!scheme.equalsIgnoreCase("forward")) { - Assert.hasText(this.uri.getHost(), - "The parameter [" + this.uri + "] format is incorrect, host can not be empty"); + if (scheme.equalsIgnoreCase("localhost")) { + // common error + // TODO: find a general way to detect without breaking existing behavior + throw new IllegalArgumentException( + "The parameter [" + this.uri + "] format is incorrect, scheme can not be localhost"); } if (this.uri.getPort() < 0 && scheme.startsWith("http")) { // default known http ports