File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
src/main/java/vigo/com/viewgorithm/config Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change 1111import org .springframework .security .config .http .SessionCreationPolicy ;
1212import org .springframework .security .web .SecurityFilterChain ;
1313import org .springframework .security .web .authentication .UsernamePasswordAuthenticationFilter ;
14+ import org .springframework .web .cors .CorsConfiguration ;
15+ import org .springframework .web .cors .CorsConfigurationSource ;
1416import vigo .com .viewgorithm .member .handler .CustomLogoutSuccessHandler ;
1517import vigo .com .viewgorithm .member .jwt .*;
1618
19+ import java .util .List ;
20+
1721@ Configuration
1822@ EnableWebSecurity
1923@ RequiredArgsConstructor
@@ -31,6 +35,22 @@ public AuthenticationManager authenticationManager(AuthenticationConfiguration c
3135 @ Bean
3236 public SecurityFilterChain filterChain (HttpSecurity http ) throws Exception {
3337 http
38+ .cors (c -> {
39+ CorsConfigurationSource source = request -> {
40+ var cors = new CorsConfiguration ();
41+ //허용할 origin
42+ cors .addAllowedOriginPattern ("*" );
43+ //허용할 method(CRUD)
44+ cors .setAllowedMethods (List .of ("*" ));
45+ //허용할 헤더
46+ cors .setAllowedHeaders (List .of ("*" ));
47+ cors .setAllowCredentials (true );
48+ cors .setMaxAge (3600L );
49+ return cors ;
50+ };
51+ c .configurationSource (source );
52+ }
53+ )
3454 .csrf (AbstractHttpConfigurer ::disable )
3555 .formLogin (AbstractHttpConfigurer ::disable )
3656 .httpBasic (AbstractHttpConfigurer ::disable )
@@ -49,4 +69,4 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
4969
5070 return http .build ();
5171 }
52- }
72+ }
You can’t perform that action at this time.
0 commit comments