nginx 서버에 빌드후 production으로 배포했을 때 콘솔에 아래와 같은 에러가 발생.
새로고침 할 때마다 아래의 에러가 반복됨.
GET http://${domain}/_next/static/8VOzb4rZM5teVSZeEjc3d/_buildManifest.js net::ERR_ABORTED 404 (Not Found)
GET http://${domain}/_next/static/8VOzb4rZM5teVSZeEjc3d/_ssgManifest.js net::ERR_ABORTED 404 (Not Found)브라우저 캐시 문제로 로드 밸런서(LB)가 두개 이상의 WAS서버를 관리 할 때 캐시의 충돌로 인한 경로 문제.
때문에 페이지를 새로고침 할 때마다 파일을 찾고 못찾고가 반복됨.
next.config.js에 마지막 깃의 커밋 아이디를 경로로 사용하도록 한다.
{next.config.js}
const execSync = require("child_process").execSync;
const lastCommitCommand = "git rev-parse HEAD";
module.exports = {
async generateBuildId() {
return execSync(lastCommitCommand).toString().trim();
},
};