Description
After upgrade to spring boot 3.0.3, Swagger authorization stopped working on http://localhost:8080
.
The issue is caused by changed method:
private static URI resolveBaseUrl(HttpServerRequest request) throws URISyntaxException {
String scheme = getScheme(request);
InetSocketAddress hostAddress = request.hostAddress();
...
}
From:
private static URI resolveBaseUrl(HttpServerRequest request) throws URISyntaxException {
String scheme = getScheme(request);
String header = request.requestHeaders().get(HttpHeaderNames.HOST);
...
}
The root cause of issue is that instead of resolving host to http://localhost
, it resolves http://[0:0:0:0:0:0:0:1]
.
The main functionality of swagger works with this IP address, but authorization fails because it redirects to:
To fix that issue I can set server.address
, but then it breaks accessing swagger by external IP.
I found the issue after checking swagger, but rest of application works fine. Should openapi be fixed or resolveBaseUrl
method?
Even enforcing IP4 by -Djava.net.preferIPv4Stack=true
does not solve issue.
Downgrading to spring-web 6.0.4 solves the issue. Also using IP instead of DSN does not generate such issues.