diff --git a/src/main/java/uk/gov/beis/els/api/openapi/OpenApiConfig.java b/src/main/java/uk/gov/beis/els/api/openapi/OpenApiConfig.java index 5ef32bf1..bb60f9e7 100644 --- a/src/main/java/uk/gov/beis/els/api/openapi/OpenApiConfig.java +++ b/src/main/java/uk/gov/beis/els/api/openapi/OpenApiConfig.java @@ -6,6 +6,7 @@ import java.util.Map; import java.util.TreeMap; import org.springdoc.core.customizers.OpenApiCustomizer; +import org.springdoc.core.customizers.ServerBaseUrlCustomizer; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -31,4 +32,14 @@ public OpenApiCustomizer sortSchemasAlphabetically() { }; } + @Bean + ServerBaseUrlCustomizer serverBaseUrlCustomizer() { + return baseUrl -> { + if (baseUrl.startsWith("http://localhost")) { + return baseUrl; + } + return baseUrl.replace("http://", "https://"); + }; + } + }