Node Express Gateway多个API端点

问题描述 投票:0回答:1

我正在尝试使用Node Express API Gateway创建多个端点,但它似乎无法正常工作。我想做的是:

localhost:8080 / api / v1 / patients => localhost:8002 / api / v1 / patients

localhost:8080 / api / v1 / doctors => localhost:8003 / api / v1 /医生

等等..

http:
  port: 8080
apiEndpoints:
  patients:
    host: 'localhost'
    paths: '/api/v1/*'
  doctors:
    host: 'localhost'
    paths: '/api/v1/*'    
serviceEndpoints:
  patients:
    url: 'http://localhost:8003'
  doctors:
    url: 'http://localhost:8002'    
policies:
  - basic-auth
  - cors
  - expression
  - key-auth
  - log
  - oauth2
  - proxy
  - rate-limit
pipelines:
  patients:
    apiEndpoints:
      - patients
    policies:
    # Uncomment `key-auth:` when instructed to in the Getting Started guide.
    # - key-auth:
      - proxy:
          - action:
              serviceEndpoint: patients
              changeOrigin: true
  doctors:
    apiEndpoints:
      - doctors
    policies:
    # Uncomment `key-auth:` when instructed to in the Getting Started guide.
    # - key-auth:
      - proxy:
          - action:
              serviceEndpoint: doctors
              changeOrigin: true              
node.js api express api-gateway
1个回答
0
投票

我们不应该做通配符,设置完整路径工作。

...
  patients:
    host: localhost
    paths: '/api/v1/patients'
  doctors:
    host: localhost
    paths: '/api/v1/doctors'
...
© www.soinside.com 2019 - 2024. All rights reserved.