[英]Express gateway cannot GET
I am trying to setup multiple (nodejs) services in express gateway, but, for some reason, the second service is not picked up. 我正在尝试在快速网关中设置多个(nodejs)服务,但是由于某种原因,第二个服务没有被使用。 Please find below my gateway.config.yml 请在下面找到我的gateway.config.yml
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
That is expected, because apiEndpoints config part uses the same host and path to build routing 这是预料之中的,因为apiEndpoints配置部分使用相同的主机和路径来构建路由
apiEndpoints:
config:
host: localhost
actions:
host: localhost
what you can do is to somehow separate it by path 您可以做的是通过某种方式将其分开
apiEndpoints:
config:
path: /configs
actions:
path: /actions
in that way localhost/configs/db
will go to config service ..:3002/configs/db
and localhost/actions/magic
will go to actions ..:3006/actions/magic
这样, localhost/configs/db
将进入配置服务..:3002/configs/db
而localhost/actions/magic
将进入操作..:3006/actions/magic
you may also want to install Rewrite plugin https://www.express-gateway.io/docs/policies/rewrite/ 您可能还需要安装重写插件https://www.express-gateway.io/docs/policies/rewrite/
in case target services have different URL patterns 如果目标服务具有不同的URL模式
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.