react 배포 관련 에러

Tony·2023년 3월 28일
0

react

목록 보기
72/82

이슈 1. React-router-dom으로 설정된 경로에서 새로 고침시 404

원인

  • 웹서버(nginx)에서 루트 경로가 아닌 하위 경로와 리액트 앱을 연결하지 못해서 발생

조치

  • nginx 설정 수정
# nginx.conf 파일
location / {
  ...
  try_files $uri.html $uri $uri/ /index.html;
  ...
}

이슈 2. Uncaught SyntaxError: Unexpected token '<' (흰 화면 이슈)

조치

  • package.json에 "homepage": "." 을 추가
  • public/index.html의 head에 <base href="/"> 를 추가

참고

profile
움직이는 만큼 행복해진다

0개의 댓글