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

Cors issues with 6.2.0 #13633

Open
neilmusgrove opened this issue Sep 11, 2024 · 0 comments
Open

Cors issues with 6.2.0 #13633

neilmusgrove opened this issue Sep 11, 2024 · 0 comments

Comments

@neilmusgrove
Copy link

neilmusgrove commented Sep 11, 2024

Expected Behavior

  • Able to configure multiple cors mappings in runtime.groovy
  • Able to use Spring Boot cors setting allowedOriginPatterns

Actual Behaviour

Attempting to configure mappings in runtime.groovy in the style recommended here: #12719 (comment) I am unable to get working in 6.2.0. Debugging the code I can see the URL paths have lost the special characters (slashes) which I think is leading to them not being picked up.

image

Using yaml config the slashes appear in the keys shown. I did try various other groovy syntax to see if I could preserve the path properly but wasn't able to get it working.

In addition I am trying to use the Spring setting allowedOriginPatterns to support wildcard subdomains however it doesn't appear to work. Looking at https://github.com/grails/grails-core/blob/c0ac9667e5d55db544cd62155ad17f8322ca1b25/grails-web-url-mappings/src/main/groovy/grails/web/mapping/cors/GrailsCorsConfiguration.groovy I seems like that setting isn't processed but I cannot find another way to utilise that style of CORS config.

It would be good to find out whether I'm doing something wrong or if this is a bug/improvement, then if there is any possibility of a fix in V6. Thanks

Steps To Reproduce

Grails 6.2.0
Configuring Cors with multiple urls mappings and wildcard subdomains in runtime.groovy.

For example:

grails {
    cors {
        enabled = true
        allowedOrigins = []
        allowedOriginPatterns = []
        mappings {
            "/word/googleOnly" {
                allowedOrigins = ['https://www.google.com']
            }
            "/word/anywhere" {
                allowedOrigins = ['*']
            }
        }

    }
}

or

grails {
    cors {
        enabled = true
        allowedOrigins = []
        allowedOriginPatterns = []
        mappings {
            "/word/googleOnly" {
                allowedOriginPatterns = ['https://*.google.com']
            }
            "/word/anywhere" {
                allowedOrigins = ['*']
            }
        }

    }
}

Environment Information

  • Grails 6.2.0
  • Groovy 3.0.21
  • Groovy antlr4 disabled (massive performance hit if not disabled)

Example Application

No response

Version

6.2.0

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

No branches or pull requests

1 participant