Skip to content

Commit

Permalink
Merge pull request #9 from 2024-ITShow-MToM/main
Browse files Browse the repository at this point in the history
✨ [Feat] (#6) CORS 설정을 위한 WebConfig 클래스 추가
  • Loading branch information
seonyo authored May 7, 2024
2 parents bb043d0 + d2a059d commit 41035b3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[DB ERD 보러가기](https://www.erdcloud.com/d/BQct5sp4MpNhgRvDK)
30 changes: 30 additions & 0 deletions src/main/java/com/MtoM/MtoM/domain/conifg/WebConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.MtoM.MtoM.domain.conifg;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Service;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

// CORS 설정을 위한 WebConfig 클래스
@RequiredArgsConstructor
@Configuration
@Service
public class WebConfig implements WebMvcConfigurer {

@Bean
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurer() {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOriginPatterns("*")
.allowedHeaders("*")
.allowedMethods("GET", "POST", "PUT", "DELETE", "HEAD", "OPTIONS" , "PATCH")
.exposedHeaders("Authorization", "RefreshToken")
.allowCredentials(true);
}
};
}

}

0 comments on commit 41035b3

Please sign in to comment.