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

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jiyun0220 committed Aug 27, 2024
2 parents 9db3be6 + b020725 commit d453816
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ https://www.oracle.com/java/technologies/downloads/

0-1-2. mac에서 자바 설치

오라클 홈페이지에서 맥 os 자바 17을 설치한다.
https://www.oracle.com/java/technologies/downloads/
이 링크로 다운받습니다
https://download.oracle.com/java/17/latest/jdk-17_macos-aarch64_bin.dmg

터미널에서 아래 명령어를 차례로 입력합니다.
```
Expand Down Expand Up @@ -107,7 +107,7 @@ export PATH

다음 명령어를 입력하여 환경변수를 적용한다.
```
source .bash_profile
source ~/.bash_profile
```

```
Expand Down
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 All @@ -34,7 +38,8 @@ public PasswordEncoder passwordEncoder() {
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
return http
.csrf(AbstractHttpConfigurer::disable)
.cors(AbstractHttpConfigurer::disable)
// .cors(AbstractHttpConfigurer::disable)
.cors(corsConfigurer -> corsConfigurer.configurationSource(corsConfigurationSource()))
.formLogin(AbstractHttpConfigurer::disable)
.httpBasic(AbstractHttpConfigurer::disable)
.rememberMe(AbstractHttpConfigurer::disable)
Expand Down Expand Up @@ -72,4 +77,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 d453816

Please sign in to comment.