【发布时间】:2017-03-30 08:36:46
【问题描述】:
我将我的 Spring Boot 应用程序部署在 Apache 支持的反向代理后面。该代理已经正确设置了标题X-Forwarded-Proto 和X-Forwarded-Host。但是,spring-data-rest 会生成奇怪的实体和端点链接。
例如。请求news 资源:
GET https://myproxyhost.net/api/news
对此作出回应:
{
"_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
}
}
正如您所见,链接以某种方式翻了一番,我不知道为什么。我使用的唯一 spring-data-rest 特定属性是:
spring.data.rest.base-path=/api
此外,在我的本地设置中,一切正常,所以我猜代理对此负有某种责任。
有人知道这里出了什么问题吗?提前致谢!
【问题讨论】:
标签: spring apache spring-data-rest spring-hateoas