From d5364e547e25b9c359bafbda7089f86be6ad4635 Mon Sep 17 00:00:00 2001 From: bflykky Date: Wed, 31 Jul 2024 16:20:58 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20CORS=20=EC=84=A4=EC=A0=95,=20=EB=B0=B0?= =?UTF-8?q?=ED=8F=AC=20=EC=84=9C=EB=B2=84=20=EB=8F=84=EB=A9=94=EC=9D=B8=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../naoman/global/config/SwaggerConfig.java | 2 +- .../umc/naoman/global/config/WebMvcConfig.java | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/umc/naoman/global/config/WebMvcConfig.java diff --git a/src/main/java/com/umc/naoman/global/config/SwaggerConfig.java b/src/main/java/com/umc/naoman/global/config/SwaggerConfig.java index dfac8c7..ec20131 100644 --- a/src/main/java/com/umc/naoman/global/config/SwaggerConfig.java +++ b/src/main/java/com/umc/naoman/global/config/SwaggerConfig.java @@ -22,7 +22,7 @@ public OpenAPI openAPI() { SecurityRequirement securityRequirement = new SecurityRequirement().addList("bearerAuth"); Server server = new Server(); - server.setUrl("https://www.naoman.site"); + server.setUrl("https://naoman.site"); Server local = new Server(); local.setUrl("http://localhost:8080"); diff --git a/src/main/java/com/umc/naoman/global/config/WebMvcConfig.java b/src/main/java/com/umc/naoman/global/config/WebMvcConfig.java new file mode 100644 index 0000000..4753279 --- /dev/null +++ b/src/main/java/com/umc/naoman/global/config/WebMvcConfig.java @@ -0,0 +1,18 @@ +package com.umc.naoman.global.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class WebMvcConfig implements WebMvcConfigurer { + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**") + .allowedOriginPatterns("*") + .allowCredentials(true) + .allowedMethods("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS") + .allowedHeaders("*") + .maxAge(3600); + } +}