From d11a109906a1be24d929039328ac8fb61fddad5f Mon Sep 17 00:00:00 2001 From: thsghdud13 Date: Sat, 28 Sep 2024 20:36:40 +0900 Subject: [PATCH] =?UTF-8?q?feat=20:=20CORS=20=EA=B4=80=EB=A0=A8=20?= =?UTF-8?q?=EC=9D=B4=EC=8A=88=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Be9room/festime/config/WebConfig.java | 20 +++++++++++++++++++ .../festime/controller/MemberController.java | 1 + 2 files changed, 21 insertions(+) create mode 100644 src/main/java/Be9room/festime/config/WebConfig.java diff --git a/src/main/java/Be9room/festime/config/WebConfig.java b/src/main/java/Be9room/festime/config/WebConfig.java new file mode 100644 index 0000000..7a1eeb7 --- /dev/null +++ b/src/main/java/Be9room/festime/config/WebConfig.java @@ -0,0 +1,20 @@ +package Be9room.festime.config; + +import lombok.RequiredArgsConstructor; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +@RequiredArgsConstructor +public class WebConfig implements WebMvcConfigurer { + + @Override + public void addCorsMappings(CorsRegistry registry) { + registry + .addMapping("/**") + .allowedHeaders("*") + .allowedOrigins("http://localhost:5173", "https://inhafestime.com") + .allowedMethods("*"); + } +} diff --git a/src/main/java/Be9room/festime/controller/MemberController.java b/src/main/java/Be9room/festime/controller/MemberController.java index e422d14..37070fd 100644 --- a/src/main/java/Be9room/festime/controller/MemberController.java +++ b/src/main/java/Be9room/festime/controller/MemberController.java @@ -5,6 +5,7 @@ import Be9room.festime.common.RandomNameGenerator; import Be9room.festime.dto.MemberDto; import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController;