title: Issue with CORS configuration on Spring Cloud Gateway
body: <p>I am trying to build Gateway proxy using Spring Cloud Gateway.</p>
  
  <p>I am able to route my requests to respective services using RouteLocator in Spring Cloud. But I am not able to configure CORS for the paths which are routing through RouteLocator.</p>
  
  <p>I tried all the possibilities which are mentioned in the Spring Cloud document.</p>
  
  <p>I am facing following error in my webpage:
  <a href="https://i.stack.imgur.com/48az7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/48az7.png" alt="enter image description here"></a></p>
  
  <p>My code looks like 
  <strong>Application.java</strong></p>
  
  <pre><code>@SpringBootApplication
  public class Application {
  
  public static void main(String[] args) {
      SpringApplication.run(Application.class, args);
  }
  
  // tag::route-locator[]
  @Bean
  public RouteLocator myRoutes(RouteLocatorBuilder builder) {
      return builder.routes()
              .route(p -&gt; p
                      .path("/order/**")
                      .filters(f -&gt; f.setResponseHeader("Access-Control-Allow-Origin", "http://localhost:8081")
                      )
                      .uri("http://localhost:9090"))
              .route(p -&gt; p
                      .path("/priority-model/selection/**")
                      .filters(f -&gt; f.addResponseHeader("Access-Control-Allow-Origin", "http://localhost:8081")
                      )
                      .uri("http://localhost:9090"))
              .build();
  }
  
  }
  </code></pre>
  
  <p><strong>application.yml</strong></p>
  
  <pre><code>server:
    port: 8080
  
  spring:
    cloud:
      gateway:
        globalcors:
          corsConfigurations:
            '[/**]':
              allowedOrigins: "*"
              allowedMethods:
                - GET
  </code></pre>
  
  <p><strong>buils.gradle</strong></p>
  
  <pre><code>    buildscript {
      repositories {
          mavenCentral()
      }
      dependencies {
          classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.5.RELEASE")
      }
  }
  
  apply plugin: 'java'
  apply plugin: 'eclipse'
  apply plugin: 'idea'
  apply plugin: 'org.springframework.boot'
  apply plugin: 'io.spring.dependency-management'
  
  bootJar {
      baseName = 'gs-gateway'
      version =  '0.1.0'
  }
  
  repositories {
      mavenCentral()
  }
  
  sourceCompatibility = 1.8
  targetCompatibility = 1.8
  
  dependencyManagement {
      imports {
          mavenBom "org.springframework.cloud:spring-cloud-dependencies:Finchley.SR2"
      }
  }
  
  dependencies {
      compile("org.springframework.cloud:spring-cloud-starter-gateway")
      compile("org.springframework.cloud:spring-cloud-starter-netflix-hystrix")
      compile("org.springframework.cloud:spring-cloud-starter-contract-stub-runner"){
          exclude group: "org.springframework.boot", module: "spring-boot-starter-web"
      }
      compile group: 'org.springframework.cloud', name: 'spring-cloud-gateway-webflux', version: '2.0.2.RELEASE'
      testCompile("org.springframework.boot:spring-boot-starter-test")
  }
  </code></pre>