Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
cors
Browse files Browse the repository at this point in the history
  • Loading branch information
osoohynn committed Aug 27, 2024
1 parent 87301d5 commit 63ebec7
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.CorsConfigurationSource;

import java.util.Collections;

@Configuration
@RequiredArgsConstructor
Expand Down Expand Up @@ -72,4 +76,15 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
.addFilterBefore(jwtExceptionFilter, JwtAuthenticationFilter.class)
.build();
}

CorsConfigurationSource corsConfigurationSource() {
return request -> {
CorsConfiguration config = new CorsConfiguration();
config.setAllowedHeaders(Collections.singletonList("*"));
config.setAllowedMethods(Collections.singletonList("*"));
config.setAllowedOriginPatterns(Collections.singletonList("*"));
config.setAllowCredentials(true);
return config;
};
}
}

0 comments on commit 63ebec7

Please sign in to comment.