Gregg
Gregg

Reputation: 35864

Grails 2.0 Redirect Include App Context Even Though I Have It Set To "/"

Using Grails 2.0.1 (upgraded from 1.3.7). In application.properties I have app.context = "/" and all is generally working well. However, my redirects now attempt to include an app context.

redirect action: "edit", id:genAttribute.id

So instead of

http://localhost:8080/genAttribute/edit/55

I end up with

http://localhost:8080/bh/genAttribute/edit/55

which of course doesn't work. Another interesting piece of this is that the g:link tag works fine. It just seems to be the redirect calls from my controllers.

Upvotes: 2

Views: 929

Answers (2)

Ingo Kegel
Ingo Kegel

Reputation: 47995

The problem is an invalid grails.serverURL config property, it's explained here in the "Redirects" section, quoting:

As a side-effect, the redirect() is now dependent on the grails.serverURL configuration setting. If this doesn't match the URL of your application, redirects will stop working.

The simplest way to avoid this problem is to remove the setting unless you need it. If you need it (usually for production deployments) then the value should already match the URL of your application. This mostly impacts development where old projects often have a legacy value that doesn't work.

Upvotes: 1

Gregg
Gregg

Reputation: 35864

I just stumbled across this so the solution is to remove the grails.serverURL from Config.groovy.

Upvotes: 2

Related Questions