이번엔 이상하게 프론트에서 GET 요청을 보낼 때만 CORS 에러가 떴다
access to XMLHttpRequest at 'https://42bb-124-111-225-247.ngrok-free.app/items?page=1&size=10' from origin 'http://localhost:3000/' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
해결방법
알고 보니 ngrok 주소로 접속하게 되면 저런 페이지가 뜨게 돼서 그런 것이었고.
아래에 To remove this page라며 페이지 지우는 방법이 쓰여있다.
프론트에서 get 요청에 헤더를 넣어주면 된다.
headers: {
'Content-Type': `application/json`,
'ngrok-skip-browser-warning': '69420',
},
헤더를 넣어주면 데이터가 잘 들어간다!