wimdeblauwe / htmx-spring-boot

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

Prepend context path to context relative URLs in htmx response headers #135

Closed xhaggi closed 2 weeks ago

xhaggi commented 4 weeks ago

I have noticed that URLs that can be set in htmx response headers e.g. HX-Redirect are not automatically interpreted as context relative. This is a bit annoying because you have to manually prepend the context path in your controller method. And that's why I've changed this behavior. Each URL starts with a slash ("/") is interpreted as context relative to the current ServletContext and therefore the context path will be prepended to the URL.

It is also possible to deactivate this behavior in the HtmxResponse.Builder and in all relevant annotations e.g @HxRedirect etc.

xhaggi commented 3 weeks ago

@wimdeblauwe rebased and ready to go in.