Skip to content

[User] 친구요청 수락API 호출 시, CORS 에러 발생 #301

@jihyun-j

Description

@jihyun-j

어떤 버그인가요?

친구 요청이 왔을 때, 친구신청 수락 API를 호출 했을 때 일어나는 에러입니다.

어떤 상황에서 발생한 버그인가요?

오늘 친구신청 수락기능을 구현을 하고 있었고, 친구신청 수락 요청을 아래와 같이 axios/patch를 사용해서 요청했습니다.

export const acceptFriendRequest = async (
  userId: string,
  friendId: string,
  token: string | null
) => {
  const url = `${process.env.REACT_APP_BASE_URL}/user/api/v1/user/${userId}/friend/${friendId}`;

  try {
    const response = await axios({
      method: "patch",
      url,
      headers: {
        Authorization: `Bearer ${token}`,
      },
    });

    console.log(response.data);
    return response.data;
  } catch (error) {
    console.error(error);
  }
};

아래의 스크린샷과 같이 에러가 발생합니다.
Screenshot 2024-11-20 at 10 04 34 PM

예상 결과

친구의 userId가 결과값으로 나와야합니다. 이 userId결과값을 사용해서 친구목록 추가에 사용할 예정입니다.

참고할만한 자료(선택)

Metadata

Metadata

Assignees

Labels

User유저 관련기능bug버그

Type

No type
No fields configured for issues without a type.

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions