Skip to content

Commit

Permalink
[refactor] : CorsConfig 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
chahyunsoo committed May 9, 2024
1 parent 3c87475 commit 69dba66
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/main/java/seoul/gonggong/global/config/CorsConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,21 @@
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;

import java.util.Arrays;

@Configuration
public class CorsConfig {
@Bean
public CorsFilter corsFilter() {
UrlBasedCorsConfigurationSource urlBasedCorsConfigurationSource = new UrlBasedCorsConfigurationSource();
CorsConfiguration configuration = new CorsConfiguration();
configuration.setAllowCredentials(true);
configuration.addAllowedOrigin("*");
configuration.setAllowedOrigins("http://localhost:3000");
configuration.addAllowedHeader("*");
configuration.addAllowedMethod("*");
configuration.setAllowedMethods(Arrays.asList("HEAD", "GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"));

urlBasedCorsConfigurationSource.registerCorsConfiguration("**", configuration);
return new CorsFilter(urlBasedCorsConfigurationSource);
}

}

0 comments on commit 69dba66

Please sign in to comment.