Skip to content

Commit

Permalink
Merge pull request #23 from 9oormthon-univ/fix/GOORM-7-cors
Browse files Browse the repository at this point in the history
[GOORM-7]-preflight 요청 처리
  • Loading branch information
sunny2you authored Nov 23, 2024
2 parents 1b5d1b5 + d16698c commit 3a046bc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
24 changes: 24 additions & 0 deletions src/main/java/com/goormthon3/team49/common/auth/CorsConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.goormthon3.team49.common.auth;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;

@Configuration
public class CorsConfig {

@Bean
public CorsFilter corsFilter() {
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(true); // 쿠키나 인증 정보를 포함한 요청 허용
config.addAllowedOrigin("http://localhost:3000"); // 허용할 Origin
config.addAllowedHeader("*"); // 모든 헤더 허용
config.addAllowedMethod("*"); // 모든 HTTP 메서드 허용 (GET, POST, PUT, DELETE 등)
source.registerCorsConfiguration("/**", config);
return new CorsFilter(source);
}
}

18 changes: 0 additions & 18 deletions src/main/java/com/goormthon3/team49/common/auth/WebConfig.java

This file was deleted.

0 comments on commit 3a046bc

Please sign in to comment.