【发布时间】:2019-02-18 23:49:25
【问题描述】:
我有一个在本地运行的 spring webapp。它工作得非常好,并且在重定向时完美地将 flash 属性传递给另一个控制器。
当我在 openshift 上抛出这个问题时,使用 https 路由时,flash 属性功能会停止工作。但是,如果我使用 http 路由,它仍然可以正常工作。
这是我的重定向传递方法,它在路径中接收一个 id,执行一些逻辑并重定向到 /foo 端点,通过 someVariable。
@GetMapping("/foo/{someId}")
public ModelAndView redirectFoo(@RequestHeader HttpHeaders headers, @PathVariable(value = "someId") String someId, RedirectAttributes attributes) {
//..some logic
attributes.addFlashAttribute("someVariable", someVariable);
return new ModelAndView("redirect:/foo");
}
redirectFoo 重定向到 /foo 并通过 flash 属性将 someVariable 传递给 /foo
@GetMapping("/foo")
public ModelAndView get(@RequestHeader HttpHeaders headers, @ModelAttribute("someVariable") String someVariable) {
//...some logic with someVariable...
return new ModelAndView("foo");
}
这一切都在本地工作得很好。但是当我把它放在 openshift 上时,它就不能正常工作了。
*编辑:这似乎不是 openshift 问题,而是 https 问题。如果我使用 http 路由,则 flash 属性可以正常工作。如果我使用 https 路由,他们不会。
【问题讨论】:
-
你能用 https 路由做一个 curl -Iv 吗?
-
您的应用程序可能必须配置为遵循
X-Forwarded-Proto标头,该标头指示外部路由器正在终止的协议,并在构建响应中的完整 URL 时使用它。现在,当通过服务路由访问时,它可能一直使用httpURL 响应而不是https。 -
@GrahamDumpleton 这正是正在发生的事情,你是对的。当它重定向时,它会重定向到
httpURL,而不是https。你知道如何配置它吗?
标签: java spring https openshift