[英]I cannot access the data I want on Express-Gateway
干得好伙计们。
我使用 Node JS 开发的项目在 8001 PORT 运行
http://localhost:8001/companies_getAll (return data)
我将使用 EXPRESS-GATEWAY,因为我想安装微服务构建。 但是,虽然我进行了以下设置,但数据并没有返回给我。
http://localhost:8080/user (return "404 Not Found!")
http://localhost:8080/user/companies_getAll (return "Cannot GET /user/companies_getAll")
在Node JS方面,我有这样的命令。
const expressEndpoints = require('./endpoints/main')
expressApplication.use(expressEndpoints)
expressApplication.use((req, res) => {
res.status(200).send('404 Not Found!')
})
expressApplication.listen(8001, () => {
console.log('---------------------------------')
console.log('Running User Service, PORT: 8001')
console.log('---------------------------------')
})
最后我有这样一个 YAML 文件。
http:
port: 8080
admin:
port: 9876
host: localhost
apiEndpoints:
api:
host: localhost
paths: '/user'
serviceEndpoints:
user:
url: 'http://localhost:8001'
policies:
- basic-auth
- cors
- expression
- key-auth
- log
- oauth2
- proxy
- rate-limit
- rewrite
pipelines:
default:
apiEndpoints:
- api
policies:
- proxy:
- action:
serviceEndpoint: user
changeOrigin: true
我无法访问“companies_getAll”。 你能帮我解决这个问题吗?
在apiEndpoints 部分,路径使用完全匹配; 您需要完整指定它:
paths: '/users/companies_getAll'
或使用通配符:
paths: '/users/*'
或者有一个路径数组
paths:
- '/user'
- '/user/companies_getAll'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.