wimdeblauwe / htmx-spring-boot

Spring Boot and Thymeleaf helpers for working with htmx
Apache License 2.0
436 stars 41 forks source link

Add Context Path to HtmxResponse browser redirect #45

Closed sthato closed 1 year ago

sthato commented 1 year ago

If I have setup a context path on my application.yml server.servlet.context-path: /bot-webapp if I return new HtmxResponse().browserRedirect("/") , it doesn't automatically add the context path. I have to manually add it to the return new HtmxResponse().browserRedirect("/bot-webapp")

klu2 commented 1 year ago

I would not implement that, the org.springframework.web.servlet.view.RedirectView also does not consider the server.servlet.context-path

In your above example, if you do that

@GetMapping("/redirect")
public View redirect() {
    return new RedirectView("/redirect-target");
}

And you then perform GET /bot-webapp/redirect then your target will be /redirect-target instead of /bot-webapp/redirect-target - you would need to add the context-path parameter here as well.

So I'd stick with the default behaviour of Spring MVC here.

wimdeblauwe commented 1 year ago

Thanks for this information @klu2 I will indeed align with the default behaviour of Spring MVC.