Skip to content

Commit

Permalink
[FIX] docs 반영 cors 설정 변
Browse files Browse the repository at this point in the history
  • Loading branch information
happyjamy committed Feb 19, 2024
1 parent 456bcd5 commit 5c28f83
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import io.oeid.mogakgo.domain.auth.jwt.JwtAuthenticationFilter;
import io.oeid.mogakgo.domain.auth.oauth.GithubOAuth2UserService;
import io.oeid.mogakgo.domain.auth.oauth.OAuth2AuthenticationSuccessHandler;
import java.util.Arrays;
import java.util.List;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
Expand Down Expand Up @@ -63,10 +65,10 @@ SecurityFilterChain filterChainApi(HttpSecurity http) throws Exception {
public CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration configuration = new CorsConfiguration();

configuration.addAllowedOrigin("*");
configuration.addAllowedHeader("*");
configuration.addAllowedMethod("*");
configuration.setAllowCredentials(true);
configuration.setAllowedOrigins(Arrays.asList("*"));
configuration.setAllowedMethods(Arrays.asList("GET","POST","PUT","DELETE","PATCH","OPTIONS"));
configuration.setAllowedHeaders(Arrays.asList("*"));
// configuration.setAllowCredentials(true);

UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", configuration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,21 @@
import java.util.List;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@EnableWebMvc
public class WebMvcConfig implements WebMvcConfigurer {

@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
resolvers.add(new UserIdAnnotationResolver());
}

@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**");
}
}

0 comments on commit 5c28f83

Please sign in to comment.