If we add cookies to a service, as shown in the following figure:
public static void set(HttpServletResponse response,String name,String value,int maxAge) {
Cookie cookie = new Cookie(name, value);
cookie.setPath("/");
cookie.setMaxAge(maxAge);
response.addCookie(cookie);
}
But when we call the service, we call the interface through the Spring Cloud gateway service, so we can't find the passed cookie on the gateway service application.
Solution:
The following configuration needs to be added to the service gateway:
zuul:
# 过滤客户端请求中的和该配置项匹配的headers,全部服务忽略敏感头(全部服务都可以传递cookie)
sensitive-headers: