I have a WebFlux application that is behind nginx-ingress
.
In order to have redirect working (for purposes of Spring Security OAuth) I enabled ForwardedHeaderTransformer
.
Now redirects generated by Spring Security OAuth are working fine, but the problem arises when I want to access my API exposed by RouterFunction
s.
For instance I have an endpoint GET /someresource
. When request is made ForwardedHeaderTransformer
adds /api/myservice
both to contextPath
and uri
.
Question is how to expose my api without adding /api/myservice
to router function?
Is there any (clean) option to strip contextPath
(if it's present) and serve API like this:
fun router() = router {
"/someresource".nest {
GET("/", myHandler::getResource)
GET("/{id}", myHandler::getResources)
Maybe there is a WebFilter
that can be triggered just before RouterFunction
s or maybe it can be modified in the other way?
I've tried to add HandlerFilterFunction
to my router. But it does not work since there is no mapping for /api/myservice
registered.