I deployed my Spring Boot application behind an Apache powered reverse proxy. This proxy already sets the headers X-Forwarded-Proto
and X-Forwarded-Host
correctly. However, spring-data-rest generates weird entity and enpoint links. Eg requesting the news
resource:
GET https://myproxyhost.net/api/news
responses with this:
{
"_embedded" : {
"news" : [ {
"title" : "Testnews",
"_links" : {
"self" : {
"href" : "https://myproxyhost.net/api/news/api/news/1"
},
"news" : {
"href" : "https://myproxyhost.net/api/news/api/news/1{?projection}",
"templated" : true
}
}
} ]
},
"_links" : {
"self" : {
"href" : "https://myproxyhost.net/api/news/api/news"
},
"profile" : {
"href" : "https://myproxyhost.net/api/news/api/profile/news"
},
"search" : {
"href" : "https://myproxyhost.net/api/news/api/news/search"
}
},
"page" : {
"size" : 20,
"totalElements" : 1,
"totalPages" : 1,
"number" : 0
}
}
As you can see the links are somehow doubled and I have no idea why. The only spring-data-rest specific property I use is:
spring.data.rest.base-path=/api
Additionally in my local setup everything works fine, so I guess the proxy is somehow responsible for this.
Has anybody an idea what is going wrong here? Thanks in advance!
The problem was an incorrect configuration of the ReverseProxy settings which led to urls like
http://proxiedhost.net:8080//api/news
Which led therefore to the weird urls mentioned in the question above.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.