Giter VIP home page Giter VIP logo

Comments (11)

zuihou avatar zuihou commented on June 7, 2024

前端调用 /api/oauth/anyTenant/login 接口时, 前端设置请求头、经过网关网关也会设置请求头。

但feign 调用时, 请求只会经过 FeignAddHeaderRequestInterceptor 拦截器,FeignAddHeaderRequestInterceptor拦截器不是所有请求头都会传递,具体传递那些,请参考源码中HEADER_NAME_LIST。 你在调用方,手动设置请求头,/anyTenant/login 接口能正常获取。

from lamp-cloud.

Angle-bo avatar Angle-bo commented on June 7, 2024

我遇到的问题很奇怪。本地代码运行,没出现问题,打包运行docker就出现获取不到Header中的值。
我这边的调用流程是这样的:A服务Controller中通过feign调用oauth的/anyTenant/login,A服务中request可以获取到Header中的Authorization,但是在oauth中的login方法中通过request获取Header中的Authorization是空值。

from lamp-cloud.

Angle-bo avatar Angle-bo commented on June 7, 2024

之前用的4.13.2没出现这个问题,升级4.14.0。之后出现了这个问题。
查了一下,只是升级了parent下pom中的相关依赖。并没有改具体的代码。
目前没找到具体的问题,先回退到4.13.2正常使用。

from lamp-cloud.

zuihou avatar zuihou commented on June 7, 2024

4.14.0升级了 spring-cloud 相关依赖,不知道会不会影响 FeignAddHeaderRequestInterceptor

from lamp-cloud.

zuihou avatar zuihou commented on June 7, 2024

在 FeignAddHeaderRequestInterceptor 中打日志看看有没有执行吧

from lamp-cloud.

Angle-bo avatar Angle-bo commented on June 7, 2024

目前分析的情况是,新版本中,出错是因为FeignAddHeaderRequestInterceptor 没有执行导致的。暂时没找到具体原因。
微信截图_20230713140101

from lamp-cloud.

Angle-bo avatar Angle-bo commented on June 7, 2024

spring-cloud-starter-alibaba-seata 2021.0.5.0 发生了变更,添加了SeataFeignRequestInterceptor,执行了SeataFeignRequestInterceptor没执行FeignAddHeaderRequestInterceptor。导致feign请求没有封装请求头。现回退到2021.0.4.0正常使用。
看了一下最新的2021.1版本,又改回跟 2021.0.4.0相似的结构,去掉了SeataFeignRequestInterceptor。但是引用2021.1版本启动项目会报错。循环依赖,目前现降版本2021.0.4.0使用,后续再研究具体是哪里的原因。

图片2021.0.4.0与2021.0.5.0的区别
微信截图_20230713145749

from lamp-cloud.

Angle-bo avatar Angle-bo commented on June 7, 2024

微信截图_20230713151030

from lamp-cloud.

Angle-bo avatar Angle-bo commented on June 7, 2024

目前发现使用2021.0.5.0版本OpenFeignAutoConfiguration没有执行,FeignAddHeaderRequestInterceptor没有自动注册,导致没有执行。

from lamp-cloud.

zuihou avatar zuihou commented on June 7, 2024

启动时,OpenFeignAutoConfiguration是否加载取决于:
image

from lamp-cloud.

zuihou avatar zuihou commented on June 7, 2024

已解决

from lamp-cloud.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.