fegin 微服务token问题

This commit is contained in:
zhangdaiscott 2020-09-20 18:29:28 +08:00
parent 0e870168d0
commit 06c879978c
1 changed files with 6 additions and 1 deletions

View File

@ -36,7 +36,12 @@ public class FeignConfig {
HttpServletRequest request = attributes.getRequest();
log.info("Feign request: {}", request.getRequestURI());
// 将token信息放入header中
requestTemplate.header(CommonConstant.X_ACCESS_TOKEN, request.getHeader(CommonConstant.X_ACCESS_TOKEN));
String token = request.getHeader(CommonConstant.X_ACCESS_TOKEN);
if(token==null){
token = request.getParameter("token");
}
log.info("Feign request token: {}", token);
requestTemplate.header(CommonConstant.X_ACCESS_TOKEN, token);
}
};
}