pongasoft / glu

Deployment Automation Platform
Apache License 2.0
521 stars 99 forks source link

Glu console does more absolute url redirects with 4.7.0 #213

Closed ypujante closed 11 years ago

ypujante commented 11 years ago

From the forum... http://glu.977617.n3.nabble.com/Glu-console-does-more-absolute-url-redirects-with-4-7-0-td4025588.html

ypujante commented 11 years ago

The code that handles redirect in grails 1.3.5 and grails 2.2.1 has changed quite a bit and explain the difference:

For 1.3.5: https://github.com/grails/grails-core/blob/v1.3.5/src/java/org/codehaus/groovy/grails/web/metaclass/RedirectDynamicMethod.java#L207

String redirectUrl = useJessionId ? response.encodeRedirectURL(actualUri) : actualUri;
response.sendRedirect(redirectUrl);

For 2.2.1: https://github.com/grails/grails-core/blob/v2.2.1/grails-plugin-controllers/src/main/groovy/org/codehaus/groovy/grails/web/metaclass/RedirectDynamicMethod.java#L174

String absoluteURL = actualUri.contains("://") ? actualUri : serverBaseURL + actualUri;
String redirectUrl = useJessionId ? response.encodeRedirectURL(absoluteURL) : absoluteURL;
int status = permanent ? HttpServletResponse.SC_MOVED_PERMANENTLY : HttpServletResponse.SC_MOVED_TEMPORARILY;

response.setStatus(status);
response.setHeader(HttpHeaders.LOCATION, redirectUrl);

So in 1.3.5, grails was generating a relative url and was letting the container handle the creation of the redirect link. In 2.2.1, grails has added the notion of a {{LinkGenerator}} which they use everywhere and generate the absolute URL themselves based on the {{grails.serverURL}} config parameter which explains the behavior we are seeing.

URL handling is a very tricky issue and I am not sure which solution is better.

ypujante commented 11 years ago

Won't fix: according to the forum thread,

I confirm that not mentioning the grails.serverURL in the configuration works for us, and it will be fine in our setup.

which is the solution found there: http://stackoverflow.com/questions/12064567/grails-redirect-issue-with-domain-name-changing

ypujante commented 11 years ago

Reopening because of Dashboard extra redirect

ypujante commented 11 years ago

fixed in glu 4.7.1