(2022.08.18)
라우팅을 알게 된 후로 해결하지 못한 Cannot GET을 해결
React-router URLs don't work when refreshing or writing manually
I'm using React-router and it works fine while I'm clicking on link buttons, but when I refresh my webpage it does not load what I want. For instance, I am in localhost/joblist and everything is fine
stackoverflow.com
처음엔 이걸 찾았다가, 다른 곳에서 Ngnix나 아파치를 쓰라고 했고, 친구 말도 아파치로 맞아떨어지길래 그래야 하나 싶었고
그 다음엔 해쉬라우터를 쓰는 방법도 찾았지만 :
결국 이걸 보고 해결했다.
https://jerimo.github.io/express/cannot-get-error/
[Express] Cannot GET / 에러
💥 React 새로고침(또는 URL 직접 입력) 시에 Cannot GET / 에러 발생 프로젝트를 진행하던 중, 분명 프론트에서는 라우터를 지정해 주었는데 새로고침을 하면 404 NOT FOUND 에러가 발생하며 페이지가 뜨
jerimo.github.io
before
(2022.08/19)
리액트 네이티브로 큐뱃 타이머 모바일용을 만들지, 큐뱃을 먼저 만들지 고민이 살짝 됐으나 일단 큐뱃 베이스부터 다지기로 했다.
큐뱃과 큐뱃 타이머를 분리하고, 큐뱃을 만들기 시작했다.
깃헙 레포도 새로 만들고, 기존의 큐뱃 타이머는 http://cubat-timer.herokuapp.com 로, 이제부터 만들 큐뱃은 http://cubat.herokuapp.com 으로.
그리고 라우팅관련 하나 더
URL에 따라 페이지의 일부만 변하고 그게 가령 /a/a, /a/b 이면, 항상 보이는 컴포넌트는 /a/* 와 같이 설정해주니 잘 됐다.
그리고 페이지 이동은 this.props.history.push('/') 를 먼저 알게 됐는데, props 가 undefined라고 에러가 나서 찾아보니
tps://www.angularfix.com/2022/01/react-typescript-module-has-no-exported.html
React-Typescript: Module '"react-router-dom"' has no exported member 'RouteComponentProps'
AngularFix contains a large number of fixes for Angular, AngularJS, Typescript, HTML, CSS and Javascript related issues. Daily Updated!
www.angularfix.com
react-router-dom의 withRouter를 사용하라는 걸 먼저 찾긴 했지만, 결국 이렇게 해결했다.
'Coding > React' 카테고리의 다른 글
MERN 웹 배포 : OCI & ubuntu & nginx (0) | 2022.08.30 |
---|---|
큐뱃 개발일지 5/22 ~ 5/26 (0) | 2022.08.24 |
props.history.push() 안됨 (0) | 2022.08.19 |
Cannot GET (express) (0) | 2022.08.18 |
큐뱃 개발 - 2022.08.02 (0) | 2022.08.04 |