Search code examples
grailsgrails-4

grails 4 url mapping for root not working


In url mappings:

     "/$controller/$action?/$id?"{
                constraints {
                // apply constraints here
                }
     }
    "/index"(controller: 'home', action: 'index')
    "/"(controller: 'home', action: 'index')

If the user uses index with the root url it redirects fine.

Controllers + action redirects fine.

But the root ("/") itself does not redirect to the home controller.

I'm also using spring security

grails.plugin.springsecurity.controllerAnnotations.staticRules = [
    [pattern: '/',               access: ['permitAll']],
    [pattern: '/index',          access: ['permitAll']]
]

What simple thing am I missing?


Solution

  • I've hit the same issue mapping the root, the only workaround I've found so far is to replace the controller and action with a uri: , e.g.

    "/"(uri: "/home/index") // in place of (controller: 'home', action: "/index")