SPA 배포 시 라우팅 설정은 필수!!
하나의 HTML 페이지로 이루어진 웹 애플리케이션,
JavaScript를 통해 동적으로 컨텐츠를 업데이트함.
SPA는 서버가 모든 경로에 대해 index.html을 반환하도록 설정해야 함!
그렇지 않으면 /login 같은 경로에 직접 접근할 때 서버가 해당 파일을 찾지 못해서
404 에러가 발생
Vercel은 내 프로젝트를 SPA로 배포해주는 플랫폼!!
해결 과정에서 생성한 vercel.json 파일:
{
"rewrites": [
{
"source": "/(.*)",
"destination": "/index.html"
}
],
"headers": [
{
"source": "/manifest.webmanifest",
"headers": [
{
"key": "Content-Type",
"value": "application/manifest+json"
},
{
"key": "Cache-Control",
"value": "public, max-age=0, must-revalidate"
}
]
},
{
"source": "/sw.js",
"headers": [
{
"key": "Cache-Control",
"value": "public, max-age=0, must-revalidate"
}
]
}
]
}
- rewrites: 모든 경로(/.*)를 index.html로 리다이렉트
- headers: PWA 지원을 위한 manifest와 service worker 설정
- PWA 지원 및 캐시 최적화 설정 추가
| 로컬 시간대와 배포 시간대가 다르게 표시되는 문제 (JPA Auditing) (1) | 2025.06.10 |
|---|---|
| GitHub Actions 배포 문제 (0) | 2025.05.28 |
| GitHub Actions AWS SSM 배포 시 "UnrecognizedClientException" 오류 해결 (0) | 2025.05.25 |
| @AuthenticationPrincipal로 로그인 유저의 정보를 가져오지 못하는 문제 (0) | 2025.05.04 |
| tailwind 커스텀 색상이 적용되지 않는 문제 (0) | 2025.05.02 |