Skip to content

Commit

Permalink
Merge pull request #71 from KUSITMS-30th-TEAM-A/fix/#70/cors
Browse files Browse the repository at this point in the history
[feat] : 배포 도메인 및 임시 도메인 cors를 허용한다
  • Loading branch information
bbbang105 authored Nov 12, 2024
2 parents 3041554 + e8ea9b8 commit c0b28da
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,13 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
@Bean
public CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration configuration = new CorsConfiguration();
configuration.setAllowedOrigins(Arrays.asList("http://localhost:5173", "http://localhost:3000", "https://git.hitzone.store"));
configuration.setAllowedOrigins(Arrays.asList(
"http://localhost:3000",
"https://git.hitzone.store",
"https://frontenddev-t5wq.vercel.app",
"https://hitzone.site",
"https://www.hitzone.site"
));
configuration.setAllowedMethods(Collections.singletonList("*"));
configuration.setAllowCredentials(true);
configuration.setAllowedHeaders(Collections.singletonList("*"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public GetStadiumInfosResponseDto getStadiumInfos(String stadiumName) {
StadiumInfo stadiumInfo = getStadiumInfoByName(stadiumName);
List<GetStadiumInfosResponseDto.ZoneInfo> zoneInfos = getZonesNameAndColorFromStadium(getStatusTypesByName(stadiumName));

return GetStadiumInfosResponseDto.of(stadiumInfo.getImgUrl(), stadiumInfo.getIntroduction(), stadiumInfo.getFirstBaseSide(), stadiumInfo.getThirdBaseSide(), zoneInfos);
return GetStadiumInfosResponseDto.of(stadiumInfo.getImgUrl(), stadiumInfo.getFirstBaseSide(), stadiumInfo.getThirdBaseSide(), zoneInfos);
}

private StadiumInfo getStadiumInfoByName(String stadiumName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,17 @@
@RequiredArgsConstructor
public enum StadiumInfo {

LG_HOME("https://kr.object.ncloudstorage.com/hitzone-bucket/hitzone/guide/lg/guide_home_lg.png",
"서울의 자존심, LG 트윈스 / 미라클 두산, 두산 베어스",
LG_HOME("https://kr.object.ncloudstorage.com/hitzone-bucket/hitzone/guide/lg/guide_home_lg.svg",
"두산베어스, LG 트윈스",
"상대팀"
),
KT_HOME("https://kr.object.ncloudstorage.com/hitzone-bucket/hitzone/guide/kt/guide_home_kt.png",
"한국 프로 야구의 10번째 심장 KT wiz",
KT_HOME("https://kr.object.ncloudstorage.com/hitzone-bucket/hitzone/guide/kt/guide_home_kt.svg",
"KT WIZ",
"상대팀"
)
;

private final String imgUrl;
private final String introduction;
private final String firstBaseSide;
private final String thirdBaseSide;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@

public record GetStadiumInfosResponseDto(
String imgUrl,
String introduction,
String firstBaseSide,
String thirdBaseSide,
List<ZoneInfo> zones
) {
public static GetStadiumInfosResponseDto of(String imgUrl, String introduction, String firstBaseSide, String thirdBaseSideList, List<ZoneInfo> zoneInfos) {
return new GetStadiumInfosResponseDto(imgUrl, introduction, firstBaseSide, thirdBaseSideList, zoneInfos);
public static GetStadiumInfosResponseDto of(String imgUrl, String firstBaseSide, String thirdBaseSideList, List<ZoneInfo> zoneInfos) {
return new GetStadiumInfosResponseDto(imgUrl, firstBaseSide, thirdBaseSideList, zoneInfos);
}

public record ZoneInfo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public class StadiumController {
private final StadiumService stadiumService;

/**
* 해당 스타디움의 홈 이미지, 소개 문구, 구역 이름 & 색상 리스트를 조회한다.
* @return 홈 이미지, 소개 문구, 구역 이름 & 색상 리스트
* 해당 스타디움의 홈 이미지, 구역 이름 & 색상 리스트를 조회한다.
* @return 홈 이미지, 구역 이름 & 색상 리스트
*/
@GetMapping("/stadium/zones")
public ResponseEntity<ApiResponse<GetStadiumInfosResponseDto>> getStadiumInfos(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ public class StadiumControllerTest extends ControllerTestConfig {
public void getZonesName() throws Exception {
// given
GetStadiumInfosResponseDto getStadiumInfosResponseDto = GetStadiumInfosResponseDto.of(
"https://kr.object.ncloudstorage.com/hitzone-bucket/hitzone/guide/lg/guide_home_lg.png",
"서울의 자존심, LG 트윈스 / 미라클 두산, 두산 베어스",
"https://kr.object.ncloudstorage.com/hitzone-bucket/hitzone/guide/lg/guide_home_lg.svg",
"두산베어스, LG 트윈스",
"상대팀",
List.of(
Expand Down Expand Up @@ -72,8 +71,7 @@ public void getZonesName() throws Exception {
.andExpect(jsonPath("$.isSuccess").value(true))
.andExpect(jsonPath("$.code").value("200"))
.andExpect(jsonPath("$.message").value("해당 스타디움의 정보가 조회되었습니다."))
.andExpect(jsonPath("$.payload.imgUrl").value("https://kr.object.ncloudstorage.com/hitzone-bucket/hitzone/guide/lg/guide_home_lg.png"))
.andExpect(jsonPath("$.payload.introduction").value("서울의 자존심, LG 트윈스 / 미라클 두산, 두산 베어스"))
.andExpect(jsonPath("$.payload.imgUrl").value("https://kr.object.ncloudstorage.com/hitzone-bucket/hitzone/guide/lg/guide_home_lg.svg"))
.andExpect(jsonPath("$.payload.firstBaseSide").value("두산베어스, LG 트윈스"))
.andExpect(jsonPath("$.payload.thirdBaseSide").value("상대팀"))
.andExpect(jsonPath("$.payload.zones[0].zoneName").value("레드석"))
Expand All @@ -94,7 +92,6 @@ public void getZonesName() throws Exception {
fieldWithPath("message").type(JsonFieldType.STRING).description("응답 메시지"),
fieldWithPath("payload").type(JsonFieldType.OBJECT).description("응답 데이터").optional(),
fieldWithPath("payload.imgUrl").type(JsonFieldType.STRING).description("이미지 URL"),
fieldWithPath("payload.introduction").type(JsonFieldType.STRING).description("스타디움 소개"),
fieldWithPath("payload.firstBaseSide").type(JsonFieldType.STRING).description("1루석 설명"),
fieldWithPath("payload.thirdBaseSide").type(JsonFieldType.STRING).description("3루석 설명"),
fieldWithPath("payload.zones[]").type(JsonFieldType.ARRAY).description("구역 정보 리스트"),
Expand Down

0 comments on commit c0b28da

Please sign in to comment.