简体   繁体   English

我无法在 Express-Gateway 上访问我想要的数据

[英]I cannot access the data I want on Express-Gateway

Good work guys.干得好伙计们。

My project that I developed with Node JS is running at 8001 PORT我使用 Node JS 开发的项目在 8001 PORT 运行

http://localhost:8001/companies_getAll (return data)

I will use EXPRESS-GATEWAY as I want to install a microservice build.我将使用 EXPRESS-GATEWAY,因为我想安装微服务构建。 However, although I make the settings below, the data is not returned to me.但是,虽然我进行了以下设置,但数据并没有返回给我。

http://localhost:8080/user (return "404 Not Found!")
http://localhost:8080/user/companies_getAll (return "Cannot GET /user/companies_getAll")

On the Node JS side, I have such an order.在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('---------------------------------')
})

and finally I have such a YAML file.最后我有这样一个 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

I can't get to "companies_getAll".我无法访问“companies_getAll”。 Can you help me with this?你能帮我解决这个问题吗?

In the apiEndpoints section , the path uses an exact match;apiEndpoints 部分,路径使用完全匹配; you'll need to specify it just in full:您需要完整指定它:

paths: '/users/companies_getAll'

Or use a wildcard:或使用通配符:

paths: '/users/*'

Or have an array of paths或者有一个路径数组

paths:
- '/user'
- '/user/companies_getAll'

    

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Vue.js & Express-gateway CORS 请求 - Vue.js & Express-gateway CORS request 为什么我不能使用节点在 express 中发布数据? - Why I cannot post data in express with nodes? 我想遍历DOM,但无法访问数据 - I want to traverse across the DOM , I am not able to access the data 如何快速访问POST请求中的数据? - How do I access the data in a POST request in express? 使用 express 时如何访问表单中的 ejs 数据 - How do i access ejs data in a form while using express 如果用户在 express js 中尝试访问登录路由时已经登录,我想重定向到仪表板 - I want to redirect to dashboard if user is already logged in when he try to access login route in express js 使用 post with express:我想从用户那里接收数据,然后用一个新文件将该数据发送回用户 - Using post with express: I want to receive data from the user and then send that data back to the user with a new file Express js 请求正文不是我想要的 - Express js request body is not excatcly i want 我想限制用户通过API访问其他用户的数据 - I want to restrict a user to access data of other users through API 我不想用快递发回表单数据,但它确实如此,还是它? - I don't want to send form data back with express, but it does, or does it?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM