Express Gateway,请求转换器未向 body 和 header 添加参数

Express Gateway, Request transformer not adding parameters to body and header

我想向我的快速网关添加参数,

我遵循了官方文档。 所以我的管道是这样的:

- name: shop
    apiEndpoints:
      - shop
    policies:
      - proxy:
          - action:
              serviceEndpoint: shopsrv
              changeOrigin: true
      - request-transformer:
        - action:
            body:
              add:
                hello: "'world'"
            headers:
              add:
                r-test: "'header value'"

当我向 express-gateway/shop 服务发送请求时,网关正常工作。

但是当我记录请求 header 并从商店服务请求 body 时

 req.body : 

 {}
 -----------------

 req.headers : 
 {
   connection: 'upgrade',
   host: 'ec2-54-245-43-241.us-west-2.compute.amazonaws.com',
   'accept-encoding': 'gzip, deflate, br',
   'postman-token': '031920ee-c3e9-4b2f-9464-2e2c1edb3c41',
   accept: '*/*',
   'user-agent': 'PostmanRuntime/7.28.4',
   'eg-request-id': '0hPlQg2jp7ar700zvniG2P'
 }

为什么我无法向请求添加任何参数? 问题出在哪儿?请帮忙!

documentation for the proxy policy声明代理策略必须放在最后;您需要重新排序管道以符合此要求:

- name: shop
    apiEndpoints:
      - shop
    policies:
      - request-transformer:
        - action:
            body:
              add:
                hello: "'world'"
            headers:
              add:
                r-test: "'header value'"
      - proxy:
          - action:
              serviceEndpoint: shopsrv
              changeOrigin: true