Spring 云网关修改 HREF 静态 HTML
Spring Cloud Gateway to modify HREF static HTML
我有一个 Spring 网关和它背后的 Webflux 服务。路线是;
server:
port: 9999
spring:
application:
name: discovery-service
cloud:
gateway:
routes:
- id: route1
predicates:
- Path=/1/**
uri: http://localhost:8081
filters:
- RewritePath=/1/(?<myPath>.*), /$\{myPath}
如果我请求 localhost:9999/1/index.html
,它会转换为 localhost:8081/index.html
并且页面正确 returned。
但是,在 HTML 我有链接和参考,例如
<a href="/microService1">test1</a>
我如何使用更正的 HREF 获得通往 return 和 HTML 的网关? (即 return HTML 作为);
<a href="/1/microService1">test1</a>
旁注;在包含微服务的 Webflux/Netty 服务器中托管静态 HTML、CSS 和 JS 是常见的还是公认的做法,还是应该将它们放在其他地方?
您只需删除 href 中的第一个 /
<a href="microService1">test1</a>
或添加一个 .
<a href="./microService1">test1</a>
我有一个 Spring 网关和它背后的 Webflux 服务。路线是;
server:
port: 9999
spring:
application:
name: discovery-service
cloud:
gateway:
routes:
- id: route1
predicates:
- Path=/1/**
uri: http://localhost:8081
filters:
- RewritePath=/1/(?<myPath>.*), /$\{myPath}
如果我请求 localhost:9999/1/index.html
,它会转换为 localhost:8081/index.html
并且页面正确 returned。
但是,在 HTML 我有链接和参考,例如
<a href="/microService1">test1</a>
我如何使用更正的 HREF 获得通往 return 和 HTML 的网关? (即 return HTML 作为);
<a href="/1/microService1">test1</a>
旁注;在包含微服务的 Webflux/Netty 服务器中托管静态 HTML、CSS 和 JS 是常见的还是公认的做法,还是应该将它们放在其他地方?
您只需删除 href 中的第一个 /
<a href="microService1">test1</a>
或添加一个 .
<a href="./microService1">test1</a>