【问题标题】:Express Gateway get "Cannot get"快速网关获取“无法获取”
【发布时间】:2020-04-27 14:33:23
【问题描述】:

我遵循 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】:

终于找到了解决办法。

- action: serviceEndpoint: {apiName} ignorePath: false prependPath: true stripPath: true

下添加路径选项

【讨论】:

    猜你喜欢
    • 2015-10-17
    • 1970-01-01
    • 2016-02-01
    • 2016-04-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-29
    • 1970-01-01
    相关资源
    最近更新 更多