[英]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.