繁体   English   中英

Express Gateway,请求转换器未将参数添加到正文和 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 并从商店服务请求正文时

 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'
 }

为什么我不能在请求中添加任何参数? 问题出在哪里? 请帮忙!

代理策略的文档说明代理策略必须排在最后; 您需要重新排序管道以符合以下要求:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM