Skip to content

Commit 12bd413

Browse files
committed
fix : Cors에 Domain 추가 및 Swagger 설정
1 parent 05d7d11 commit 12bd413

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

src/main/java/inu/codin/codin/global/config/SecurityConfig.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import inu.codin.codin.global.auth.filter.TokenValidationFilter;
66
import inu.codin.codin.global.auth.jwt.JwtTokenValidator;
77
import lombok.RequiredArgsConstructor;
8+
import org.springframework.beans.factory.annotation.Value;
89
import org.springframework.context.annotation.Bean;
910
import org.springframework.context.annotation.Configuration;
1011
import org.springframework.security.access.hierarchicalroles.RoleHierarchy;
@@ -31,8 +32,11 @@ public class SecurityConfig {
3132
private final JwtTokenValidator jwtTokenValidator;
3233
private final CustomAccessDeniedHandler customAccessDeniedHandler;
3334

35+
@Value("${server.domain}")
36+
private String BASE_DOMAIN_URL;
37+
3438
@Bean
35-
public SecurityFilterChain filterChain(HttpSecurity http, CorsConfigurationSource corsConfigurationSource) throws Exception {
39+
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
3640
return http
3741
.cors(cors -> cors.configurationSource(corsConfigurationSource()))
3842
.csrf(CsrfConfigurer::disable)
@@ -67,7 +71,7 @@ public CorsConfigurationSource corsConfigurationSource() {
6771
CorsConfiguration config = new CorsConfiguration();
6872

6973
config.setAllowCredentials(true);
70-
config.setAllowedOrigins(List.of("http://localhost:3000", "https://front-end-dun-mu.vercel.app"));
74+
config.setAllowedOrigins(List.of("http://localhost:3000", BASE_DOMAIN_URL, "https://front-end-dun-mu.vercel.app"));
7175
config.setAllowedMethods(List.of("GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"));
7276
config.setAllowedHeaders(List.of("*"));
7377
config.setExposedHeaders(List.of("*"));

src/main/java/inu/codin/codin/global/config/SwaggerConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public OpenAPI customOpenAPI() {
4848
)
4949
.servers(List.of(
5050
new Server().url("http://localhost:8085").description("Local Server"),
51-
new Server().url(BASE_DOMAIN_URL).description("Production Server")
51+
new Server().url(BASE_DOMAIN_URL + "/api/lectures").description("Production Server")
5252
));
5353
}
5454

0 commit comments

Comments
 (0)