Skip to content

Commit 5fd7b7d

Browse files
authored
Merge pull request #49 from M7-TAVE/fix/48-cors-issue
fix: CORS 해결을 위해 서버 도메인 허용하도록 추가
2 parents d2fc0ea + a54f942 commit 5fd7b7d

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/main/java/com/example/travelbag/global/config/WebConfig.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import java.nio.charset.StandardCharsets;
1111

1212
@Configuration
13-
public class WebConfig {
13+
public class WebConfig implements WebMvcConfigurer {
1414

1515
@Bean
1616
public HttpMessageConverter<?> jsonMessageConverter() {
@@ -19,5 +19,13 @@ public HttpMessageConverter<?> jsonMessageConverter() {
1919
converter.setDefaultCharset(StandardCharsets.UTF_8);
2020
return converter;
2121
}
22-
}
2322

23+
@Override
24+
public void addCorsMappings(CorsRegistry registry) {
25+
registry.addMapping("/**") // 모든 경로에 대해 CORS 허용
26+
.allowedOrigins("http://www.jionly.tech", "https://www.jionly.tech") // 허용할 출처
27+
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") // 허용할 HTTP 메서드
28+
.allowedHeaders("*") // 모든 헤더 허용
29+
.allowCredentials(true); // 쿠키, 인증 정보 허용
30+
}
31+
}

0 commit comments

Comments
 (0)