From 17d7873b7f89d3c88ef0f982941e2d7ca5621657 Mon Sep 17 00:00:00 2001 From: songhaechan Date: Thu, 15 Aug 2024 17:35:55 +0900 Subject: [PATCH] =?UTF-8?q?hotfix:=20cors=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/global/config/CorsConfig.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/main/java/com/amorgakco/backend/global/config/CorsConfig.java diff --git a/src/main/java/com/amorgakco/backend/global/config/CorsConfig.java b/src/main/java/com/amorgakco/backend/global/config/CorsConfig.java new file mode 100644 index 0000000..3ddbf03 --- /dev/null +++ b/src/main/java/com/amorgakco/backend/global/config/CorsConfig.java @@ -0,0 +1,20 @@ +package com.amorgakco.backend.global.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.http.HttpHeaders; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class CorsConfig implements WebMvcConfigurer { + + @Override + public void addCorsMappings(final CorsRegistry registry) { + registry.addMapping("/**") + .allowedOrigins("http://localhost:3000") + .allowedMethods("GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS") + .allowCredentials(true) + .exposedHeaders(HttpHeaders.LOCATION); + WebMvcConfigurer.super.addCorsMappings(registry); + } +}