Feign调用远程服务时传递Cookie信息
@Configuration
public class TtpfFeignConfig {
@Bean
public RequestInterceptor requestInterceptor(){//Feign同步请求头
return template -> {
ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
if (requestAttributes != null) {
HttpServletRequest request = requestAttributes.getRequest();
template.header("Cookie",request.getHeader("Cookie"));
}
};
}
}