Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/42.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js Express gateway如何忽略路径但使用url的其余部分_Node.js_Express_Gateway_Express Gateway - Fatal编程技术网

Node.js Express gateway如何忽略路径但使用url的其余部分

Node.js Express gateway如何忽略路径但使用url的其余部分,node.js,express,gateway,express-gateway,Node.js,Express,Gateway,Express Gateway,我的配置如下 apiEndpoints: api: host: '*' paths: '/ip' approval-engine: host: '*' paths: '/app/*' serviceEndpoints: httpbin: url: 'https://httpbin.org' approval-engine: url: 'http://localhost:8001/' 以代理作为 - proxy: -

我的配置如下

apiEndpoints:
  api:
    host: '*'
    paths: '/ip'
  approval-engine:
    host: '*'
    paths: '/app/*'
serviceEndpoints:
  httpbin:
    url: 'https://httpbin.org'
  approval-engine:
    url: 'http://localhost:8001/'
以代理作为

  - proxy:
      - action:
          serviceEndpoint: approval-engine
          ignorePath: false
          prependPath: false
          autoRewrite : true
          changeOrigin: true
当我向发出请求时,请求被路由到localhost:8001/app/category


我的问题是我们能否将请求发送到。我想忽略代理中的路径:/app/part。

要完成此操作,您需要使用

您可以使用
eg
CLI安装插件

eg plugin install express-gateway-plugin-rewrite
确保网关配置的
策略
白名单中包含
重写

在处理请求的管道中,您可以像这样使用重写插件:

policies:
  - rewrite:
    - condition:
        name: regexpmatch
        match: ^/app/(.*)$
      action:
        rewrite: /$1
这应该在请求路由到服务端点之前从路径中删除
/app