Skip to content

Commit

Permalink
Refactor: CORS 설정 수정 (#10)
Browse files Browse the repository at this point in the history
어노테이션 기반 -> 설정 클래스로 변경
  • Loading branch information
pjh5365 authored Sep 2, 2024
1 parent 6a404ea commit 7d3ad15
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
24 changes: 24 additions & 0 deletions src/main/java/kaboo/kaboochat/chat/config/WebConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package kaboo.kaboochat.chat.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
* CORS 설정 등 웹 설정 클래스
*
* @author : parkjihyeok
* @since : 2024/09/02
*/
@Configuration
public class WebConfig implements WebMvcConfigurer {

@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOriginPatterns("*") // “*“같은 와일드카드를 사용
.allowedMethods("GET", "POST") // 허용할 HTTP method
.allowCredentials(true); // 쿠키 인증 요청 허용
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
Expand All @@ -27,7 +26,6 @@
* @author : parkjihyeok
* @since : 2024/08/18
*/
@CrossOrigin(origins = "http://localhost:5173", allowCredentials = "true")
@RestController
@RequestMapping("/chat")
@RequiredArgsConstructor
Expand Down

0 comments on commit 7d3ad15

Please sign in to comment.