【问题标题】:Spring Cloud Gateway - RewriteLocationResponseHeaderSpring Cloud Gateway - RewriteLocationResponseHeader
【发布时间】:2021-07-23 00:17:48
【问题描述】:

我的 Spring Cloud Gateway 配置中有以下路由:

- id: pgadmin
  uri: lb://pg-admin-service
  predicates:
  - Path=/pgadmin/**
  filters:
  - RewritePath=/pgadmin(?<segment>/?.*), $\{segment}
  - RewriteLocationResponseHeader=AS_IN_REQUEST, Location, ,    <---- this line is incorrect

请求以未经身份验证的用户身份在http://10.0.0.100/pgadmin/ 上发出。应用程序返回一个包含位置标头的响应,其值为:

http://10.0.0.100/login

浏览器尝试重定向到该 URL。相反,它应该重定向到:

http://10.0.0.100/pgadmin/login

路由定义中RewriteLocationResponseHeader 的正确值是多少?

非常感谢

JT

【问题讨论】:

  • 试试- RewriteLocationResponseHeader
  • 嗨,如果您发现了对此的破解,请提供答案。提前致谢
  • @AnjanKrishna 我在下面发布了对我们有用的内容。如果可行,请您接受答案吗?

标签: spring-boot spring-cloud spring-cloud-gateway


【解决方案1】:

如果你想重写你的路径,试试这个:

- id: docs
  uri: lb://auth-service
  predicates:
  - Path=/my-auth/**
  filters:
  - RewritePath=/my-auth(?<segment>/?.*), $\{segment}

或简单地将请求转发到您的服务:

- id: docs
  uri: lb://auth-service
  predicates:
  - Path=/my-auth/**

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-10-20
    • 2019-06-24
    • 2020-06-22
    • 2018-09-25
    • 2021-12-28
    • 2020-09-11
    • 2021-04-30
    • 2021-08-01
    相关资源
    最近更新 更多