代码之家  ›  专栏  ›  技术社区  ›  shamon shamsudeen

带快速网关的微服务:路由返回404错误

  •  1
  • shamon shamsudeen  · 技术社区  · 7 年前

    我的微服务正在端口中运行 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

    3 回复  |  直到 7 年前
        1
  •  0
  •   Vincenzo    7 年前

    一般来说,一定要复习我们的课程 Path Management Piece . 这将帮助您了解转发到服务的路径。

    /test /test* . 这会指示网关路径不完整,可能会提供其他内容。

    另外,在服务方面,我会改变 app.use app.get 所以你只听你感兴趣的动词。

    干杯!

        2
  •  -2
  •   dadidaochieng    7 年前

    我会和杰纳斯一起去- https://hellofresh.gitbooks.io/janus/

    推荐文章