Node.js Express gateway无法获取
我正在尝试在express gateway中设置多个(nodejs)服务,但由于某些原因,第二个服务未被拾取。请在下面找到my gateway.config.ymlNode.js Express gateway无法获取,node.js,express,api-gateway,Node.js,Express,Api Gateway,我正在尝试在express gateway中设置多个(nodejs)服务,但由于某些原因,第二个服务未被拾取。请在下面找到my gateway.config.yml http: port: 8080 admin: port: 9876 hostname: localhost apiEndpoints: config: host: localhost actions: host: localhost serviceEndpoints: configServi
http:
port: 8080
admin:
port: 9876
hostname: localhost
apiEndpoints:
config:
host: localhost
actions:
host: localhost
serviceEndpoints:
configService:
url: "http://localhost:3002"
actionService:
url: "http://localhost:3006"
policies:
- basic-auth
- cors
- expression
- key-auth
- log
- oauth2
- proxy
- rate-limit
pipelines:
- name: basic
apiEndpoints:
- config
policies:
- proxy:
- action:
serviceEndpoint: configService
changeOrigin: true
- name: basic2
apiEndpoints:
- actions
policies:
- proxy:
- action:
serviceEndpoint: actionService
changeOrigin: true
这是意料之中的,因为apiEndpoints配置部分使用相同的主机和路径来构建路由
apiEndpoints:
config:
host: localhost
actions:
host: localhost
你能做的就是用路径把它分开
apiEndpoints:
config:
path: /configs
actions:
path: /actions
这样,localhost/configs/db
将转到配置服务:3002/configs/db
而localhost/actions/magic
将转到actions:3006/actions/magic
您可能还想安装重写插件
如果目标服务有不同的URL模式,这对我很有帮助。但是,如果要指定路径数组,该怎么办?