Skip to content

Commit

Permalink
Fix openapi base url for PaaS envs
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesbarnett91 committed Nov 22, 2023
1 parent 9cb9319 commit dad8ab3
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/main/java/uk/gov/beis/els/api/openapi/OpenApiConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -31,4 +32,14 @@ public OpenApiCustomizer sortSchemasAlphabetically() {
};
}

@Bean
ServerBaseUrlCustomizer serverBaseUrlCustomizer() {
return baseUrl -> {
if (baseUrl.startsWith("http://localhost")) {
return baseUrl;
}
return baseUrl.replace("http://", "https://");
};
}

}

0 comments on commit dad8ab3

Please sign in to comment.