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

Bug : cors error #97

Closed
wonseok-do opened this issue Sep 7, 2022 · 5 comments
Closed

Bug : cors error #97

wonseok-do opened this issue Sep 7, 2022 · 5 comments
Assignees
Labels
bug 버그 발생

Comments

@wonseok-do
Copy link

한 일

const sendEmailVerifyCode = async () => {
    const url =
      "http://~~~/api/auth/send-email?email=wsdo970@gmail.com";
    const res = await axios.get(url, {
      headers: { "Content-Type": "application/x-www-form-urlencoded" },
    });
    console.log(res);
    return res;
  };

에러 내용

Access to XMLHttpRequest at 'http://~~~/api/auth/send-email?email=wsdo970@gmail.com' from origin
 'http://127.0.0.1:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present
 on the requested resource.

조치 사항

만약 조치한 것이 있거나 구글링한 게 있다면, ...

환경 설정

OS: Windows 10
Node:  v16.15.1 (@unchaptered), v16.13.1(@axisotherwise)
npm : v8.11.0 (@unchaptered), v8.2.2 (@axisotherwise)
@wonseok-do wonseok-do added the bug 버그 발생 label Sep 7, 2022
unchaptered added a commit that referenced this issue Sep 7, 2022
@dusunax
Copy link
Member

dusunax commented Sep 7, 2022

CORS 에러

@unchaptered
Copy link
Member

unchaptered commented Sep 7, 2022

기존에 cors 에서 허용 중인 아이피는 다음과 같습니다.

CORS_ORIGIN_ONE: 'localhost:3000',
CORS_ORIGIN_TWO: '127.0.0.1:3000'

@dusunax
Copy link
Member

dusunax commented Sep 7, 2022

content-type 에러

  • 헤더의 'content-type': "application/json"가 일치하지 않는 에러
    image

@unchaptered
Copy link
Member

다음과 같이 변경해서 해결되었습니다.

CORS_ORIGIN_ONE: 'localhost:3000',
CORS_ORIGIN_TWO: 'http://localhost:3000''

@unchaptered
Copy link
Member

unchaptered commented Sep 7, 2022

content-type 에러

  • 헤더의 'content-type': "application/json"가 일치하지 않는 에러
    image

경계원소를 고려해서 코드 변경을 했습니다.

해당 미들웨어 가 운영 환경에서 비정상 작동 하는 문제로 인해서 전부 주석처리 해두었습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 버그 발생
Projects
None yet
Development

No branches or pull requests

4 participants