springdoc-openapi-ui 如何将请求设置为HTTPS

Tab*_*hin 20 springdoc springdoc-openui

当我发布时,我会使用HTTPS请求而不是HTTP,但是swagger原始URL仍然是HTTP,我不知道如何设置,并且原始springdoc-openapi-ui配置中没有服务器的文档

https://springdoc.org/index.html#properties 在此输入图像描述

小智 21

你可以试试这个:

...
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.servers.Server;
...
@OpenAPIDefinition(servers = {@Server(url = "/", description = "Default Server URL")})

@SpringBootApplication
public class MyApplication {
...
}
Run Code Online (Sandbox Code Playgroud)

更多信息在这里https://github.com/springdoc/springdoc-openapi/issues/726


Tab*_*hin 10

我通过修改Nginx配置和Spring-boot配置\xef\xbc\x88application.properties\xef\xbc\x89解决了这个问题

\n

nginx-conf:

\n
proxy_set_header        X-Forwarded-Proto $scheme;\n
Run Code Online (Sandbox Code Playgroud)\n

弹簧启动(application.properties):

\n
proxy_set_header        X-Forwarded-Proto $scheme;\n
Run Code Online (Sandbox Code Playgroud)\n

https://github.com/springdoc/springdoc-openapi/issues/171

\n