Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/#326 vote credential #327

Merged
merged 2 commits into from
Aug 24, 2023
Merged

Feat/#326 vote credential #327

merged 2 commits into from
Aug 24, 2023

Conversation

NYeonK
Copy link
Contributor

@NYeonK NYeonK commented Aug 23, 2023

  • 브랜치명, 브랜치 알맞게 설정
  • Reviewer, Assignees, Label, Milestone, Issue(PR 작성 후에) 붙이기
  • PR이 승인된 경우 해당 브랜치는 삭제하기

📌 내용

  • 투표하기 API에만 withCredentials 설정을 적용했습니다.
  • 투표 기능의 로그인 모달을 제거했습니다.

@NYeonK NYeonK self-assigned this Aug 23, 2023
@NYeonK NYeonK linked an issue Aug 23, 2023 that may be closed by this pull request
4 tasks
@NYeonK NYeonK requested a review from ilmerry August 23, 2023 16:30
Comment on lines +10 to +14
const { data } = useSWR<PiickleSWRResponse<BallotList[]>>(
`${PATH.BALLOTS}`,
(url) => realReq.GET_SWR(url, { withCredentials: true }),
swrSetting,
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WithCredentials: true 옵션을 쓸 경우에는 쿠키로 통신하는건가요?! 비회원 로직을 서버랑 어떻게 짠건지 궁금해요!

Copy link
Contributor Author

@NYeonK NYeonK Aug 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵 맞습니다! withCredentials 설정을 통해서 투표 관련 get, post API에만 쿠키 통신을 허용했어요!

비회원은 따로 쿠키가 없기 때문에, 요청에 쿠키가 없으면 세션아이디를 따로 만들어요. 이 아이디를 사용해서 비즈니스 로직을 수행한다고 합니다! (서버)


💡 왜 투표 API에만 설정했는가!

기존에는 전역에 withCredentials: true를 설정했었는데요. 그렇게 되면 프론트에서 작업할 때, 모바일웹 확인이 어렵습니다. (로컬에서)

저희가 withCredentials 설정을 하는 것처럼, 서버 측에서도 Access-Control-Allow-Origin 설정을 해줘야 해요! 이 설정에 웹 주소가 들어가지 않으면, 저희 지금 DEV 서비스 투표 부분에 데이터가 없는 것처럼 통신을 하지 못하는데요👀

모바일주소가 알다시피.. http://IP주소:5173 라 서버에서 미리 설정을 해주지 못해요.
그래서 전역 설정하면 아예 모바일 확인이 어려우니 투표 부분만 보지 말자! 라는 차선책으로 부분 적용하게 되었습니다!!

@ilmerry 이해안가는 부분이 있다면 말해주세요😋

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아하 그래서 로컬에서는 투표 부분이 에러가 난거군요! 쿠키가 없으면 세션아이디 만드는 방법 굉장히 신박하네요,,

그러면 원래는 쿠키를 써서 로그인을 구현했다가, 최근에 그 방식을 로컬스토리지로 바꾼거 맞나요??

@NYeonK NYeonK merged commit 1dac2b3 into release/2.1.0 Aug 24, 2023
@NYeonK NYeonK deleted the feat/#326-vote_credential branch August 24, 2023 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ Vote ] 비회원 투표 기능
2 participants