2
2
3
3
import com .fasterxml .jackson .databind .ObjectMapper ;
4
4
import com .fasterxml .jackson .databind .PropertyNamingStrategies ;
5
+ import org .springframework .beans .factory .annotation .Value ;
5
6
import org .springframework .context .annotation .Bean ;
6
7
import org .springframework .context .annotation .Configuration ;
7
8
import org .springframework .security .crypto .bcrypt .BCryptPasswordEncoder ;
12
13
@ Configuration
13
14
public class ProjectConfig implements WebMvcConfigurer {
14
15
16
+ @ Value ("${spring.profiles.active}" )
17
+ private String activeProfile ;
18
+
15
19
// 암호 인코더 정의 - bcrypt 해싱 알고리즘 사용
16
20
@ Bean
17
21
public BCryptPasswordEncoder passwordEncoder () {
@@ -26,14 +30,24 @@ public ObjectMapper objectMapper() {
26
30
// 객체의 속성 이름을 snake-case로 설정
27
31
.setPropertyNamingStrategy (PropertyNamingStrategies .SNAKE_CASE );
28
32
}
29
-
30
- // Cors 모두 오픈 (개발환경)
31
33
@ Override
32
34
public void addCorsMappings (CorsRegistry registry ) {
35
+ if (activeProfile .equals ("prod" )) {
36
+ prodProfileCorsMapping (registry );
37
+ } else {
38
+ devProfileCorsMapping (registry );
39
+ }
40
+ }
41
+ // Cors 모두 오픈 (개발환경)
42
+ public void devProfileCorsMapping (CorsRegistry registry ) {
33
43
registry .addMapping ("/**" )
34
44
.allowedOriginPatterns ("*" )
35
45
.allowedMethods ("GET" , "POST" )
36
46
.allowedHeaders ("*" )
37
47
.allowCredentials (true );
38
48
}
49
+ // 프로덕션 환경에서는 Cors 설정을 Front 페이지와 허용할 서버만 등록
50
+ private void prodProfileCorsMapping (CorsRegistry registry ) {
51
+
52
+ }
39
53
}
0 commit comments