Express Gateway获得“无法获得”

问题描述 投票:0回答:1

我遵循Express Gateway入门指南。

这是示例配置

http:
  port: 8080
admin:
  port: 9876
  host: localhost
apiEndpoints:
  api:
    host: localhost
    paths: '/ip'
serviceEndpoints:
  httpbin:
    url: 'https://httpbin.org'
policies:
  - basic-auth
  - cors
  - expression
  - key-auth
  - log
  - oauth2
  - proxy
  - rate-limit
pipelines:
  default:
    apiEndpoints:
      - api
    policies:
    # Uncomment `key-auth:` when instructed to in the Getting Started guide.
    # - key-auth:
      - proxy:
          - action:
              serviceEndpoint: httpbin 
              changeOrigin: true

并且如果我运行npm start并浏览localhost:8080 / ip,则会看到响应。

但是如果我将localhost:8080 / ip导航到httpbin url时将其更改为“ localhost:3001”,则响应为“ Cannot GET ip /”。为什么???

在端口3001上,我有一个可以产生响应的工作服务

node.js express api-gateway
1个回答
0
投票

最后我找到了解决方案。在下面添加路径选项- action: serviceEndpoint: {apiName} ignorePath: false prependPath: true stripPath: true

© www.soinside.com 2019 - 2024. All rights reserved.