具有多个 URI 匹配并创建重写 URL 的虚拟服务时出现 404 错误。下面是例子。我们有一个微服务A,我们希望无论何时调用https://hostName/serviceA/它都应该被https://hostName/覆盖,并且无论何时调用 https://hostName/serviceA/scheme/ default/它应该被https://hostName/scheme/default覆盖
下面是虚拟服务的片段。
- name: service-A
match:
- uri:
prefix: /serviceA/
ignoreUriCase: true
rewrite:
uri: /
headers:
request:
add:
Cache-Control: "max-age=0, no-cache, no-store, must-revalidate"
Pragma: "no-cache"
Expires: "-1"
corsPolicy:
allowOrigins:
- exact: "*"
allowMethods:
- POST
- GET
allowCredentials: true
route:
- destination:
host: service-A
port:
number: 8080
- name: themes-service-A
match:
- uri:
prefix: /serviceA/scheme/default/
ignoreUriCase: true
rewrite:
uri: /scheme/default
headers:
request:
add:
Cache-Control: "max-age=0, no-cache, no-store, must-revalidate"
Pragma: "no-cache"
Expires: "-1"
add_header: "more_clear_headers server"
corsPolicy:
allowOrigins:
- exact: "*"
allowMethods:
- POST
- GET
allowCredentials: true
route:
- destination:
host: service-A
port:
number: 8080
但是每当我们点击https://hostName/serviceA/scheme/default/时,它都会给出 404 错误,我们可以从开发人员的工具中看到请求转到/serviceA//scheme/default/
但是所有发送到https://hostName/serviceA/的请求都会得到 200 响应。
需要您的帮助来解决此问题