title: Spring Cloud Gateway is not finding a route path (404 error)
body: <p>I am investigating Spring Cloud Gateway as an API gateway solution for a professional application and am running through this tutorial: <a href="http://spring.io/guides/gs/gateway/#scratch" rel="nofollow noreferrer">http://spring.io/guides/gs/gateway/#scratch</a>.</p>
  
  <p>However I am running into issues I cannot solve.</p>
  
  <p>Here is my POM</p>
  
  <pre><code>&lt;groupId&gt;org.springframework&lt;/groupId&gt;
  &lt;artifactId&gt;gs-gateway&lt;/artifactId&gt;
  &lt;version&gt;0.1.0&lt;/version&gt;
  
  &lt;parent&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
      &lt;version&gt;2.1.2.RELEASE&lt;/version&gt;
  &lt;/parent&gt;
  
  &lt;dependencyManagement&gt;
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
              &lt;artifactId&gt;spring-cloud-dependencies&lt;/artifactId&gt;
              &lt;version&gt;Greenwich.RC2&lt;/version&gt;
              &lt;type&gt;pom&lt;/type&gt;
              &lt;scope&gt;import&lt;/scope&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  &lt;/dependencyManagement&gt;
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
          &lt;artifactId&gt;spring-cloud-starter-gateway&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
          &lt;artifactId&gt;spring-cloud-starter-netflix-hystrix&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
          &lt;artifactId&gt;spring-cloud-starter-contract-stub-runner&lt;/artifactId&gt;
          &lt;exclusions&gt;
              &lt;exclusion&gt;
                  &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;/exclusion&gt;
          &lt;/exclusions&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  
  &lt;properties&gt;
      &lt;java.version&gt;1.8&lt;/java.version&gt;
  &lt;/properties&gt;
  
  &lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p>and here is the Application.java</p>
  
  <pre><code>@SpringBootApplication
  @RestController
  public class Application {
  
  public static void main(String[] args) {
      SpringApplication.run(Application.class, args);
  }
  
  @Bean
  public RouteLocator myRoutes(RouteLocatorBuilder builder) {
      return builder.routes()
          .route(p -&gt; p
              .path("/get")
              .filters(f -&gt; f.addRequestHeader("Hello", "World"))
              .uri("http://httpbin.org:80"))
          .build();
  }
  }
  </code></pre>
  
  <p>Running this and trying to hit <a href="http://localhost:8080/get" rel="nofollow noreferrer">http://localhost:8080/get</a> was giving me a gateway timeout.  Consulting with someone at work I discovered that I am behind a firewall and needed a proxy.  So I modified the Application.java to this:</p>
  
  <pre><code>@SpringBootApplication
  @RestController
  public class Application {
  
  public static void main(String[] args) {
      SpringApplication.run(Application.class, args);
  }
  
  @Bean
  public RouteLocator myRoutes(RouteLocatorBuilder builder) {
      return builder.routes()
          .route(p -&gt; p.host("internet.proxy.*****.com").and()
              .path("/get")
              .filters(f -&gt; f.addRequestHeader("Hello", "World"))
              .uri("http://httpbin.org:80"))
          .build();
  }
  </code></pre>
  
  <p>Now, I am no longer getting a gateway time out but now I am getting a 404 error.  Here is the output using curl <a href="http://localhost:8080/get" rel="nofollow noreferrer">http://localhost:8080/get</a>:</p>
  
  <pre><code>{"timestamp":"2019-01- 
      16T14:24:12.929+0000","path":"/get","status":404,"error":"Not 
  Found","message":null}
  </code></pre>
  
  <p>I am probably missing something simple but I cannot see it.</p>
  
  <p>EDIT:
  according to the tutorial listed above this should be the response I get back:</p>
  
  <pre><code>{
      "args": {},
      "headers": {
          "Accept": "*/*",
          "Connection": "close",
          "Forwarded": 
           "proto=http;host=\"localhost:8080\";for=\"0:0:0:0:0:0:0:1:56207\"",
          "Hello": "World",
          "Host": "httpbin.org",
          "User-Agent": "curl/7.54.0",
          "X-Forwarded-Host": "localhost:8080"
    },
    "origin": "0:0:0:0:0:0:0:1, 73.68.251.70",
    "url": "http://localhost:8080/get"
  }
  </code></pre>