spring-cloud-gateway icon indicating copy to clipboard operation
spring-cloud-gateway copied to clipboard

Add CORS functionality to spring cloud gateway mvc

Open manojsinghsaun opened this issue 1 year ago • 5 comments

I required cross origin functionality in spring gateway mvc but I am not able to use it E.g This metadata is not present in spring gateway mvc.

spring:
  cloud:
    gateway:
      routes:
      - id: cors_route
        uri: https://example.org
        predicates:
        - Path=/service/**
        metadata:
          cors
            allowedOrigins: '*'
            allowedMethods:
              - GET
              - POST
            allowedHeaders: '*'
            maxAge: 30

manojsinghsaun avatar Mar 17 '24 17:03 manojsinghsaun

Hi @spencergibb Do there will be update in next version release? can you provide some solution or work around for time being? Because I am stuck with this now.

manojsinghsaun avatar Mar 18 '24 08:03 manojsinghsaun

It can be in the next minor, but that will not be until November. In the meantime, you might be able to use normal Spring Boot configuration https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#web.servlet.spring-mvc.cors and https://docs.spring.io/spring-framework/reference/web/webmvc-cors.html

spencergibb avatar Mar 18 '24 16:03 spencergibb

@spencergibb I would be happy to contribute in this with some guidance. I pinged you on Twitter about this feature because I really need it. Thank you

akuma8 avatar May 13 '24 13:05 akuma8

PRs welcome

spencergibb avatar May 14 '24 14:05 spencergibb