-
Notifications
You must be signed in to change notification settings - Fork 472
Closed
Labels
Description
The following code gets called at some point in the linkTo(methodOn... sequence:
private UriComponents getDefaultUriString() {
return baseUri == null ? ServletUriComponentsBuilder.fromCurrentRequest().build() : baseUri;
}
This code doesn't deal with the protocol properly when proxied. So what I have is that some of my links are http and others are https. The links that happen via the ControllerLinkBuilderFactory are correct as they use the ControllerLinkBuilder.getBuilder() method that understands the "X-Forwarded-Ssl" header (which we are including in our virtual host).
I haven't fully tested but what seems to be working properly is the following (instead):
private UriComponents getDefaultUriString() {
return baseUri == null ? getBuilder().build() : baseUri;
}
private static UriComponentsBuilder getBuilder() {
HttpServletRequest request = getCurrentRequest();
ServletUriComponentsBuilder builder = ServletUriComponentsBuilder.fromRequestUri(request);
...
The rest of the getBuilder() and getCurrentRequest() methods are monkey patched/copied from the ControllerLinkBuilder.