Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to use regex expression in origin of cors configuration #1938

Closed
ShahzebAnsari opened this issue Sep 14, 2020 · 3 comments
Closed
Labels

Comments

@ShahzebAnsari
Copy link

I have multiple origin with similar name like abc.def.com, abc.ghi.com, abc.jkl.com etc. I tried to use regex so that I can just defined it in a single line configuration but it doesn't work.

Can you please tell me is it possible or not?

@tony-clarke-amdocs
Copy link
Contributor

This is not directly managed by Spring Cloud Gateway, but comes from Spring itself. You can see the relevant code here. My reading of this is that the only wild card pattern allowed is '*'.

@spencergibb
Copy link
Member

@korektur
Copy link
Contributor

I was able to use originPatterns in spring-cloud-gateway via global-cors configuration. For example:

spring:
  cloud:
    gateway:
      globalcors:
        corsConfigurations:
          '[/**]':
            allowedOriginPatterns: "https://*.spring.io"
            allowedMethods:
            - GET

Unfortunately, there is an issue with trailing '/' and generic ports as mentioned here: spring-projects/spring-framework#26892

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants