From 3dbfb803f388dab73f5250f105a612ddf690023e Mon Sep 17 00:00:00 2001 From: Song-EunJu Date: Thu, 17 Nov 2022 19:48:12 +0900 Subject: [PATCH] =?UTF-8?q?mod:=20cors=20=EC=84=B8=ED=8C=85=20=EC=98=B5?= =?UTF-8?q?=EC=85=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/example/goorm/WebMvcConfig.java | 16 ++++++++++++++-- .../java/com/example/goorm/oreum/CsvWriter.java | 6 +++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/example/goorm/WebMvcConfig.java b/src/main/java/com/example/goorm/WebMvcConfig.java index d55f0a8..e7ca745 100644 --- a/src/main/java/com/example/goorm/WebMvcConfig.java +++ b/src/main/java/com/example/goorm/WebMvcConfig.java @@ -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 @@ -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/"); } } diff --git a/src/main/java/com/example/goorm/oreum/CsvWriter.java b/src/main/java/com/example/goorm/oreum/CsvWriter.java index d91f4fe..cc47548 100644 --- a/src/main/java/com/example/goorm/oreum/CsvWriter.java +++ b/src/main/java/com/example/goorm/oreum/CsvWriter.java @@ -11,13 +11,13 @@ // //@Configuration //@RequiredArgsConstructor -//public class CsvWriter implements ItemWriter { +//public class CsvWriter implements ItemWriter { //// private final OreumRepository oreumRepository; // // private final TestRepository testRepository; // // @Override -// public void write(List list) throws Exception { -// oreumRepository.saveAll(new ArrayList(list)); +// public void write(List list) throws Exception { +// testRepository.saveAll(new ArrayList(list)); // } //} \ No newline at end of file