Skip to content

Commit

Permalink
Merge pull request #217 from Codiary-UMC-6th/refactor/#173-myPage
Browse files Browse the repository at this point in the history
Feat: cors μ—λŸ¬
  • Loading branch information
yumzen authored Aug 22, 2024
2 parents efe5905 + 716bbb2 commit 983f0c4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
.httpBasic(httpBasic -> httpBasic.disable())
.csrf(csrf->csrf.disable())
.sessionManagement(session->session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))

.authorizeHttpRequests(
authorize -> authorize
// Member κ΄€λ ¨ μ ‘κ·Ό
Expand Down Expand Up @@ -86,7 +87,7 @@ public PasswordEncoder passwordEncoder() {
CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(true);
config.setAllowedOriginPatterns(List.of("*", "http://localhost:3000"));
config.setAllowedOriginPatterns(List.of("*", "http://localhost:3000, "));
config.setAllowedOrigins(List.of("http://localhost:3000"));
config.setAllowedMethods(List.of("GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"));
config.setAllowedHeaders(List.of("*"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
if (tokenRepository.existsByNotAvailableToken(token)) {
HttpServletResponse httpResponse = (HttpServletResponse) response;
httpResponse.setContentType("application/json");
httpResponse.setHeader("Access-Control-Allow-Origin", "*");
httpResponse.setHeader("Access-Control-Allow-Methods", "POST, GET, DELETE, PUT");
httpResponse.setHeader("Access-Control-Max-Age", "3600");
httpResponse.setHeader("Access-Control-Allow-Headers", "x-requested-with, origin, content-type, accept");
httpResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);

// 였λ₯˜ λ©”μ‹œμ§€ JSON 생성
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
@RequiredArgsConstructor
@RestController
@RequestMapping("/teams")
@CrossOrigin(origins = "http://localhost:8080, http://localhost:3000")
@Tag(name = "νŒ€ API", description = "νŒ€ 생성/쑰회/μˆ˜μ • κ΄€λ ¨ APIμž…λ‹ˆλ‹€.")
public class TeamController {

Expand Down

0 comments on commit 983f0c4

Please sign in to comment.