簡體   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