【发布时间】:2019-02-14 19:08:13
【问题描述】:
我的微服务在端口3000 中运行,我正在尝试通过express-js gateway 代理请求
但是我在访问微服务中的路由时遇到了问题
微服务路线
app.use('/sample',(req,res)=>{
res.json({
message:'Run with microservice'
})
})
我可以访问这条路线http://localhost:3000/sample。
这是我的gateway.config.yml。
http:
port: 3004
admin:
port: 9876
hostname: localhost
apiEndpoints:
test:
host: localhost
paths: '/test'
serviceEndpoints:
test:
url: 'http://localhost:3002/'
policies:
- basic-auth
- cors
- expression
- key-auth
- log
- oauth2
- proxy
- rate-limit
pipelines:
test:
apiEndpoints:
- test
policies:
- proxy:
- action:
serviceEndpoint: test
changeOrigin: true
当我尝试通过http://localhost:3004/test/sample 访问我的微服务路由时,返回cannot get route error。
【问题讨论】:
标签: node.js express microservices express-gateway