[Eslint] 'React' must be in scope when using JSXeslintreact/react-in-jsx-scope
2024. 1. 10. 06:03
개발/Error note
Eslint 설정을 마치고나니 'React' must be in scope when using JSX 오류가 떴다. Eslint가 없을때는 React를 임포트 해주지않아도 Next 에서 알아서 인식을 해줬는데, Eslint 설정이 들어가고 나서는 스코프 오류가 생긴다. 해결방법1 import React from 'react' 상단에 react를 임포트를 해준다 해결방법 2 "rules": { "react/react-in-jsx-scope": "off" } eslintrc에 해당 규칙을 추가해준다
[CORS] Access to XMLHttpRequest at 'http://localhost:3065/user' from origin 'htt
2024. 1. 4. 21:10
개발/Error note
Next.js에서 Express에서 요청을 보내려고 했는데, CORS 문제가 생겼다. 교차출처 리소스 공유 [Node] Data흐름과 axios, proxy서버 사용하기페이지가 없을때는 postman을 썼지만 이제는 react-route-dom을 사용해 Router를 사용하고있다. Axios 제이쿼리 ajax생각하면된다. 서버와 클라이언트 통신에 필요한 기능 (라우팅은 아래 글 참고) [React] 페h-owo-ld.tistory.com전에는 이걸썼는데 이번에는 cors 라이브러리 사용 npm i cors 진입 파일에app.use( cors({ origin: 'http://localhost:3000', }) );추가해주니 간단하게 해결! 참고: - https://inpa.tistory.com/entry/..
[javascript] 로그인 이후 Request failed with status code 401 Unauthorized 인증오류
2023. 11. 28. 20:13
개발/Error note
로그인 이후 게시글 작성을 하려는데 401 unauthorized 오류가 떴다.왜 권한이 없다고 걸렸을까? 문제는 CORS에 있다. 이전에 프론트와 백 포트가 달라서 CORS로 포트허용 해주긴 했으나, 도메인이 다르면 쿠키가 전달이 되지않기 때문에 추가로 credentials 속성도 추가해줘야한다. // 프론트 => 프론트 여러군데에서 쓸 때는 공통 설정 해주면 된다 axios.defaults.withCredentials = true; //공통설정 function addPostAPI(data) { return axios.post( '/post', { content: data }, { withCredentials: true, } ); } // 백 app.use( cors({ origin: 'http://l..
[Javascript] client.js:1 The above error occurred in task removePost Cannot read properties of undefined (reading 'data') RangeError [ERR_HTTP_INVALID_STATUS_CODE]: Invalid status code: 10
2023. 11. 22. 21:50
개발/Error note
게시글을 삭제하는데 개발자 도구 브라우저 콘솔에서 위와같은 에러가 떴다. function* removePost(action) { console.log('removePost::', action); try { const result = yield call(removePostAPI, action.data); yield put({ type: REMOVE_POST_SUCCESS, data: result.data, }); yield put({ type: REMOVE_POST_OF_ME, data: action.data, }); } catch (err) { console.error(err); yield put({ type: REMOVE_POST_FAILURE, data: err.response.data, }); } ..
[JS] Safari에서 new Date 객체 Invalid Date 리턴 받는 경우
2023. 11. 20. 01:29
개발/Error note
원인은 Safari 에서는 new Date 객체에서의 DateType (yyyy-mm-dd)이지원되지 않는 데이터 포맷이었기 때문이다. 따라서 포맷을 yyyy/mm/dd 의 형태로 변경해서 사용해야 한다.function stringToDate(string) { if (!string) return return new Date(string.replace(/[년월일]/g, '').replace(/ /g, ',')) } 아래와 같이 수정 function stringToDate(string) { if (!string) return return new Date(string.replace(/[년월일]/g, '').replace(/ /g, '/')) } 참고: - https://stackoverflow.com/ques..