Skip to content

Commit ac866f2

Browse files
committed
fix: CORS 설정 변경
- 회원정보 수정 요청시 요청 안오는 문제
1 parent cc7cfdd commit ac866f2

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/main/java/com/BANnerIt/server/global/config/CorsConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ public WebMvcConfigurer corsConfigurer() {
1515
public void addCorsMappings(CorsRegistry registry) {
1616
registry.addMapping("/**")
1717
.allowedOrigins("https://bannerit.co.kr", "https://www.bannerit.co.kr")
18-
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
18+
.allowedMethods("GET", "POST", "PUT", "DELETE","PATCH", "OPTIONS")
1919
.allowedHeaders("*")
2020
.allowCredentials(true);
2121
}
2222
};
2323
}
24-
}
24+
}

src/main/java/com/BANnerIt/server/global/config/SecurityConfig.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
1515
import org.springframework.security.web.SecurityFilterChain;
1616
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
17+
import org.springframework.web.cors.CorsConfiguration;
18+
import org.springframework.web.cors.CorsConfigurationSource;
19+
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
1720

1821
@Configuration
1922
@RequiredArgsConstructor
@@ -51,4 +54,18 @@ public OAuth2AccessTokenResponseClient<OAuth2AuthorizationCodeGrantRequest> acce
5154
client.setRequestEntityConverter(new OAuth2AuthorizationCodeGrantRequestEntityConverter());
5255
return client;
5356
}
57+
58+
@Bean
59+
public CorsConfigurationSource corsConfigurationSource() {
60+
CorsConfiguration configuration = new CorsConfiguration();
61+
configuration.setAllowCredentials(true);
62+
configuration.addAllowedOrigin("https://bannerit.co.kr");
63+
configuration.addAllowedOrigin("https://www.bannerit.co.kr");
64+
configuration.addAllowedHeader("*");
65+
configuration.addAllowedMethod("*");
66+
67+
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
68+
source.registerCorsConfiguration("/**", configuration);
69+
return source;
70+
}
5471
}

0 commit comments

Comments
 (0)