最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

internal redirect when proxying a request from Spring Boot Gateway - Stack Overflow

programmeradmin7浏览0评论

Client (browser) -> Spring Boot Gateway throgh ngrok ( -> http://localhost:8080) -> Spring Webflux APP (https://localhost:433)

Spring WebFlux app has a controller where a local redirect is performed:

@PostMapping("login-initiation")
Mono<RedirectView> loginInitiation(ServerWebExchange exchange, WebSession webSession) {
    ...
    return clientRegistrationEntityService.findByClientId(loginInitiationRequest.clientId())
        .map(clientRegistration -> new RedirectView("/oauth2/authorization/" + clientRegistration.getRegistrationId()));
});

I expect the absolute redirect path to be https://localhost:443/oauth2/authorization/,

but instead, the actual redirect path is /oauth2/authorization/.

What is the reason for using the gateway domain instead of localhost? How can I ensure that the redirect path is https://localhost:443/oauth2/authorization/

Client (browser) -> Spring Boot Gateway throgh ngrok (https://dfsdfs-sds-prawn.ngrok-free.app -> http://localhost:8080) -> Spring Webflux APP (https://localhost:433)

Spring WebFlux app has a controller where a local redirect is performed:

@PostMapping("login-initiation")
Mono<RedirectView> loginInitiation(ServerWebExchange exchange, WebSession webSession) {
    ...
    return clientRegistrationEntityService.findByClientId(loginInitiationRequest.clientId())
        .map(clientRegistration -> new RedirectView("/oauth2/authorization/" + clientRegistration.getRegistrationId()));
});

I expect the absolute redirect path to be https://localhost:443/oauth2/authorization/,

but instead, the actual redirect path is https://dfsdfs-sds-prawn.ngrok-free.app/oauth2/authorization/.

What is the reason for using the gateway domain instead of localhost? How can I ensure that the redirect path is https://localhost:443/oauth2/authorization/

Share Improve this question asked Mar 10 at 13:07 McSimMcSim 11 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

Try to set an absolute URL:

@PostMapping("login-initiation")
Mono<RedirectView> loginInitiation(ServerWebExchange exchange, WebSession webSession) {
    ...
    return clientRegistrationEntityService.findByClientId(loginInitiationRequest.clientId())
        .map(clientRegistration -> new RedirectView("https://localhost:433/oauth2/authorization/" + clientRegistration.getRegistrationId()));
});
发布评论

评论列表(0)

  1. 暂无评论