Skip to content

Commit

Permalink
fix: 개발서버 CORS 관련 오류 해결 (#105)
Browse files Browse the repository at this point in the history
fix: cors 활성화
  • Loading branch information
uwoobeat authored Jan 5, 2024
1 parent fd376ea commit 82761e9
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.depromeet.global.config.security;

import static org.springframework.security.config.Customizer.*;

import com.depromeet.global.common.constants.SwaggerUrlConstants;
import com.depromeet.global.common.constants.UrlConstants;
import com.depromeet.global.util.SpringEnvironmentUtil;
Expand All @@ -9,7 +11,6 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
Expand Down Expand Up @@ -52,6 +53,8 @@ public PasswordEncoder passwordEncoder() {

@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {

http.cors(withDefaults());
http.csrf(AbstractHttpConfigurer::disable);

if (springEnvironmentUtil.isProdAndDevProfile()) {
Expand All @@ -64,7 +67,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
.map(SwaggerUrlConstants::getValue)
.toArray(String[]::new))
.authenticated())
.httpBasic(Customizer.withDefaults());
.httpBasic(withDefaults());
}

http.authorizeHttpRequests(
Expand Down

0 comments on commit 82761e9

Please sign in to comment.