|
1 | 1 | package net.hackyourfuture.coursehub; |
2 | 2 |
|
3 | 3 | import org.springdoc.core.customizers.ServerBaseUrlCustomizer; |
4 | | -import org.springdoc.core.properties.SpringDocConfigProperties; |
5 | | -import org.springdoc.core.properties.SwaggerUiConfigProperties; |
6 | | -import org.springdoc.core.providers.SpringWebProvider; |
7 | | -import org.springdoc.webmvc.ui.SwaggerWelcomeWebMvc; |
8 | 4 | import org.springframework.context.annotation.Bean; |
9 | 5 | import org.springframework.context.annotation.Configuration; |
10 | 6 |
|
|
14 | 10 | @Configuration |
15 | 11 | public class SwaggerBehindReverseProxyConfig { |
16 | 12 |
|
17 | | - @Bean |
18 | | - SwaggerWelcomeWebMvc swaggerWelcome(SwaggerUiConfigProperties swaggerUiConfig, SpringDocConfigProperties springDocConfigProperties, SpringWebProvider springWebProvider) { |
19 | | - if (isBehindDigitalOceanReverseProxy()) { |
20 | | - swaggerUiConfig.setUrl("/api/v3/api-docs"); |
21 | | - swaggerUiConfig.setConfigUrl("/api/v3/api-docs/swagger-config"); |
22 | | - } |
23 | | - return new SwaggerWelcomeWebMvc(swaggerUiConfig, springDocConfigProperties, springWebProvider); |
24 | | - } |
25 | | - |
26 | 13 | @Bean |
27 | 14 | ServerBaseUrlCustomizer serverBaseUrlCustomizer() { |
28 | 15 | return (serverBaseUrl, request) -> { |
29 | | - if (isBehindDigitalOceanReverseProxy()) { |
| 16 | + if (serverBaseUrl.contains("coursehub.hyf.dev")) { |
30 | 17 | return serverBaseUrl + "/api"; |
31 | 18 | } |
32 | 19 | return serverBaseUrl; |
33 | 20 | }; |
34 | 21 | } |
35 | | - |
36 | | - private boolean isBehindDigitalOceanReverseProxy() { |
37 | | - var appDomain = System.getenv("APP_DOMAIN"); |
38 | | - return appDomain != null && appDomain.contains("coursehub.hyf.dev"); |
39 | | - } |
40 | 22 | } |
0 commit comments