refactor(cors): 按环境读取允许来源并支持 uat 配置
This commit is contained in:
@@ -42,7 +42,7 @@ public class WebMvcDevConfig implements WebMvcConfigurer {
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
log.info("允许cors的地址配置:{}", Arrays.toString(corsProperties.getAllowedOrigins()));
|
||||
registry.addMapping("/**")
|
||||
.allowedOriginPatterns("*")
|
||||
.allowedOrigins(corsProperties.getAllowedOrigins())
|
||||
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
|
||||
.allowedHeaders("*")
|
||||
.allowCredentials(null == corsProperties.getAllowCredentials() || corsProperties.getAllowCredentials());
|
||||
|
||||
@@ -12,7 +12,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@Profile("prod")
|
||||
@Profile({"prod", "uat"})
|
||||
@Configuration
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
|
||||
Reference in New Issue
Block a user