Skip to content

Commit

Permalink
Merge pull request #59 from dnwls16071/fix-episodes
Browse files Browse the repository at this point in the history
fix-episodes PR
  • Loading branch information
dnwls16071 authored Dec 30, 2024
2 parents f088f28 + aab900a commit 15ff1df
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ private List<WhitelistEntry> initializeWhitelist() {
entries.add(new WhitelistEntry("/api/v3/api-docs/**", HttpMethod.GET));
entries.add(new WhitelistEntry("/api/swagger-ui/**", HttpMethod.GET));

entries.add(new WhitelistEntry("/api/animes/**", HttpMethod.GET));
entries.add(new WhitelistEntry("/api/anime/**", HttpMethod.GET));
entries.add(new WhitelistEntry("/api/episodes/**", HttpMethod.GET));
entries.add(new WhitelistEntry("/", HttpMethod.GET));

return entries;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.example.aniwhere.application.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.CorsConfigurationSource;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;

import java.util.List;

@Configuration
public class CorsConfig {

private static final String FRONT_END_LOCAL = "http://localhost:3000";

@Bean
public CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration corsConfiguration = new CorsConfiguration();

corsConfiguration.setAllowCredentials(true);
corsConfiguration.setAllowedOrigins(List.of(FRONT_END_LOCAL));
corsConfiguration.setAllowedMethods(List.of("GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"));
corsConfiguration.setAllowedHeaders(List.of("*"));
corsConfiguration.setExposedHeaders(List.of("Set-Cookie", "*"));

corsConfiguration.addAllowedHeader("*");
corsConfiguration.addAllowedMethod("*");

UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", corsConfiguration);
return source;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;
Expand All @@ -14,6 +15,7 @@

@Configuration
@RequiredArgsConstructor
@EnableWebMvc
public class WebConfig implements WebMvcConfigurer {

private final LoginUserArgumentResolver loginUserArgumentResolver;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ public String extractRefreshToken(HttpServletRequest request) {
public ResponseCookie invalidateAccessTokenCookie(String name, String value) {
return ResponseCookie.from(name, value)
.httpOnly(true)
.secure(true)
.sameSite("none")
.maxAge(0)
.path("/")
.build();
Expand All @@ -76,8 +74,6 @@ public ResponseCookie invalidateAccessTokenCookie(String name, String value) {
public ResponseCookie invalidateRefreshTokenCookie(String name, String value) {
return ResponseCookie.from(name, value)
.httpOnly(true)
.secure(true)
.sameSite("none")
.maxAge(0)
.path("/")
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
new AntPathRequestMatcher("/api/login"),
new AntPathRequestMatcher("/api/token"),
new AntPathRequestMatcher("/api/auth/**"),
new AntPathRequestMatcher("/api/animes/**"),
new AntPathRequestMatcher("/api/anime/**"),
new AntPathRequestMatcher("/api/episodes/**"),
new AntPathRequestMatcher("/recommend"),
new AntPathRequestMatcher("/anime/*"),
new AntPathRequestMatcher("/api/v3/api-docs/**"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class EpisodeApiController {
summary = "애니메이션 ID값에 대한 전체 에피소드 조회",
description = "특정 애니메이션의 모든 에피소드를 페이지 단위로 조회합니다."
)
@GetMapping("/animes/{animeId}/episodes")
@GetMapping("/anime/{animeId}/episodes")
public ResponseEntity<Page<EpisodesDto>> getEpisodes(@PathVariable(name = "animeId") Long animeId, Pageable pageable) {
Page<EpisodesDto> episodes = episodesRepository.getEpisodes(animeId, pageable);
return ResponseEntity
Expand Down

0 comments on commit 15ff1df

Please sign in to comment.