【问题标题】:Node Express Gateway multiple API endpointsNode Express Gateway 多个 API 端点
【发布时间】:2019-09-11 08:23:45
【问题描述】:

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

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

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

等等。

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】:

    我们不应该使用通配符,设置完整路径是可行的。

    ...
      patients:
        host: localhost
        paths: '/api/v1/patients'
      doctors:
        host: localhost
        paths: '/api/v1/doctors'
    ...
    

    【讨论】:

      猜你喜欢
      • 2021-03-05
      • 2017-05-16
      • 1970-01-01
      • 2021-06-19
      • 2018-11-09
      • 1970-01-01
      • 2021-10-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多