Skip to content

Commit

Permalink
mod: cors 세팅 옵션 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
Song-EunJu committed Nov 17, 2022
1 parent 96adc9e commit 3dbfb80
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
16 changes: 14 additions & 2 deletions src/main/java/com/example/goorm/WebMvcConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
Expand All @@ -11,7 +12,18 @@ public class WebMvcConfig implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("http://localhost:3000/", "https://9oorm-oreum-frontend.vercel.app/")
.allowedMethods("GET", "POST");
.allowedOrigins("*")
.allowedMethods("*")
.allowedHeaders("*")
.allowCredentials(true)
.maxAge(3600L);
}

@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/swagger-ui/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/");
registry.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/");
}
}
6 changes: 3 additions & 3 deletions src/main/java/com/example/goorm/oreum/CsvWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
//
//@Configuration
//@RequiredArgsConstructor
//public class CsvWriter implements ItemWriter<Oreum> {
//public class CsvWriter implements ItemWriter<Test> {
//// private final OreumRepository oreumRepository;
//
// private final TestRepository testRepository;
//
// @Override
// public void write(List<? extends Oreum> list) throws Exception {
// oreumRepository.saveAll(new ArrayList<Oreum>(list));
// public void write(List<? extends Test> list) throws Exception {
// testRepository.saveAll(new ArrayList<Test>(list));
// }
//}

0 comments on commit 3dbfb80

Please sign in to comment.