Spring redirect url issue when behind Zuul proxy

后端 未结 2 1065
有刺的猬
有刺的猬 2021-02-20 11:24

I\'ve been trying to get to the bottom of a strange redirection issue for the past 2 days without success.

Based on the spring-cloud example projects, I\'ve configured E

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-20 11:57

    As you can see RedirectView ignores X-FORWARDED-* headers. Simply put, you can't use "redirect:/account".

    Instead instantiate a RedirectView and configure it accordingly:

    RedirectView redirect = new RedirectView("account");
    redirect.setHosts(new String[]{ request.getHeader("X-FORWARDED-HOST") });
    

    Since Spring Framework 4.3 (currently RC1) setHosts method is available.

提交回复
热议问题