Skip to content

Commit

Permalink
Merge pull request #69 from seoshinehyo/fix/#68
Browse files Browse the repository at this point in the history
[Feat] CORS 수정
  • Loading branch information
seoshinehyo authored Dec 22, 2024
2 parents e7cf343 + ab4c6b8 commit a945246
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/main/java/com/dearnote/config/CorsConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.dearnote.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;

@Configuration
public class CorsConfig {

@Bean
public CorsFilter corsFilter() {
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(true);
config.addAllowedOriginPattern("*"); // 모든 Origin 허용
config.addAllowedHeader("*"); // 모든 Header 허용
config.addAllowedMethod("*"); // 모든 HTTP Method 허용
source.registerCorsConfiguration("/**", config);
return new CorsFilter(source);
}
}

0 comments on commit a945246

Please sign in to comment.