Skip to content

Commit

Permalink
fix(#125) : WebConfig 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
aeeazip committed Aug 22, 2023
1 parent 6feceed commit 79cdfb5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/trothly/trothcam/config/SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private CorsConfiguration getDefaultCorsConfiguration() {
configuration.setAllowedOrigins(
Arrays.asList("http://localhost:8080", "https://trothly.com", "http://localhost:3000"));
configuration.setAllowedHeaders(Arrays.asList("*")); // 모든 header 에 응답을 허용
configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE", "PATCH")); // 모든 get,post,patch,put,delete 요청 허용
configuration.setAllowedMethods(Arrays.asList("*")); // 모든 get,post,patch,put,delete 요청 허용
configuration.setAllowedOrigins(Arrays.asList("*")); // 모든 ip 응답을 허용
configuration.setAllowCredentials(true); // 내 서버가 응답할 때 json 을 자바스크립트에서 처리할 수 있게 할지를 설정하는 것
configuration.setMaxAge(3600L);
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/trothly/trothcam/config/WebConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package trothly.trothcam.config;

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

import java.util.Arrays;

@Configuration
public class WebConfig implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOriginPatterns("http://localhost:8080","http://localhost:3000", "https://trothly.com") // 허용할 출처
.allowedMethods("*") // 허용할 HTTP method
.allowCredentials(true) // 쿠키 인증 요청 허용
.allowedHeaders("*")
.maxAge(3600L); // 원하는 시간만큼 pre-flight 리퀘스트를 캐싱
}
}

0 comments on commit 79cdfb5

Please sign in to comment.