我正在尝试使用Node Express API网关创建多个端点,但似乎无法正常工作。我想做的是:
本地主机:8080 / api / v1 /患者=>本地主机:8002 / api / v1 /患者
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
答案 0 :(得分:0)
我们不应该使用通配符,而是设置完整路径。
...
patients:
host: localhost
paths: '/api/v1/patients'
doctors:
host: localhost
paths: '/api/v1/doctors'
...