We have an application in Grails 2.0 that we have working when we run on localhost:8080. In Config.groovy, the application has a grails.serverURL property that has to be set for the current host and current app name. However, in our QA environment, the middleware team takes the war we give them and deploys it to a server whose name and port we don’t know ahead of time.
It seems like Grails assumes that you are always going to register a domain name and then have full control over that name and the port the app is running, which is not the case at all.
What is the best way to address this problem? We have tried simply removing grails.serverURL, but Spring Security appears to use it for building up the url for redirects on login success and logout success.
development { grails.serverURL = "http://www.notused.com/${appName}" }
production { grails.serverURL = "<we don't know yet>" }
And before anyone asks, I have read numerous posts on StackOverflow and elsewhere that relate to this issue but do not answer this specific question.
No, Spring Security doesn’t use it. It should always be safe to remove the serverURL property and let Grails generate urls relative to the current running app.
Typically the only place you need this property is when you’re generating emails and want to embed the server url so users can click back to your site. Since these are often sent asynchronously and not during a server request, there’s no way to know the server address without a config option. But if you’re not doing that, it’s safe to omit.