Skip to content

Instantly share code, notes, and snippets.

@SergeyAlekseevN
Created April 20, 2020 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SergeyAlekseevN/415dca21d8b8f630db27dee29bef2036 to your computer and use it in GitHub Desktop.
Save SergeyAlekseevN/415dca21d8b8f630db27dee29bef2036 to your computer and use it in GitHub Desktop.
CustomWebFilter.java
**
* Workaround of https://github.com/spring-projects/spring-boot/issues/9785 from https://stackoverflow.com/a/45190717/1477873
*
* @author Sergey Alekseev
*/
@Component
public class CustomWebFilter implements WebFilter {
@NotNull
@Override
public Mono<Void> filter(ServerWebExchange exchange, @NotNull WebFilterChain chain) {
if (exchange.getRequest().getURI().getPath().equals("/")) {
return chain.filter(exchange.mutate().request(exchange.getRequest().mutate().path("/index.html").build()).build());
}
return chain.filter(exchange);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment