Adding Headers to Zuul when re-directing

后端 未结 3 1639
离开以前
离开以前 2021-01-18 07:49

I am trying to use Zuul to redirect calls to a downstream system somewhere else. In the re-direct, I need to add in a Header with necessary data for the

相关标签:
3条回答
  • 2021-01-18 07:54

    A little late my response but works fine
    As referred in the official documentation Cookies and Sensitive Headers
    The sensitiveHeaders are a blacklist, and the default is not empty. Consequently, to make Zuul send all headers (except the ignored ones), you must explicitly set it to the empty list. Doing so is necessary if you want to pass cookie or authorization headers to your back end. The following example shows how to use sensitiveHeaders:

    zuul:
      routes:
        entry:
          path: /users/**
          strip-prefix: false
          service-id: users-service
          sensitive-headers:
          - Cookie,Set-Cookie
    

    This implemented example can also help you

    0 讨论(0)
  • 2021-01-18 08:07

    I update my comment here just in case if anyone is still facing this problem. I found this problem recently and resolved by adding the following configuration in my application.yml

    application.yml ... zuul: sensitive-headers: - Cookie,Set-Cookie ...

    Reference Link below:
    https://cloud.spring.io/spring-cloud-static/Dalston.SR5/multi/multi__router_and_filter_zuul.html

    0 讨论(0)
  • I guess you use a Route Filter, maybe you can try with a Pre Filter.

    Adding a custom header can be done with something like this : context.addZuulRequestHeader("Authorization", "Basic " + credentials);.

    For the redirection part, you can check this thread

    0 讨论(0)
提交回复
热议问题