-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
cors 파일 통합
나눠진 cors 통합했습니다.
- Loading branch information
Showing
2 changed files
with
40 additions
and
26 deletions.
There are no files selected for viewing
48 changes: 24 additions & 24 deletions
48
src/main/java/com/example/healthylife/config/CorsConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
package com.example.healthylife.config; | ||
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.addAllowedOriginPattern("http://localhost:8081/swagger-ui/index.html"); | ||
config.addAllowedOriginPattern("https://trendy-healthy-backend.store/swagger-ui/"); | ||
config.addAllowedOriginPattern("https://trendy-healthy.store/"); | ||
config.addAllowedMethod("*"); // 모든 HTTP 메서드 허용 | ||
config.addAllowedHeader("*"); // 모든 헤더 허용 | ||
config.setAllowCredentials(true); // 자격 증명 허용 | ||
source.registerCorsConfiguration("/**", config); | ||
return new CorsFilter(source); | ||
} | ||
} | ||
//package com.example.healthylife.config; | ||
//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.addAllowedOriginPattern("http://localhost:8081/swagger-ui/index.html"); | ||
// config.addAllowedOriginPattern("https://trendy-healthy-backend.store/swagger-ui/"); | ||
// config.addAllowedOriginPattern("https://trendy-healthy.store/"); | ||
// config.addAllowedMethod("*"); // 모든 HTTP 메서드 허용 | ||
// config.addAllowedHeader("*"); // 모든 헤더 허용 | ||
// config.setAllowCredentials(true); // 자격 증명 허용 | ||
// source.registerCorsConfiguration("/**", config); | ||
// return new CorsFilter(source); | ||
// } | ||
//} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters