Next.js에서 커스텀 설정을 하기 위해서는 프로젝트 디렉터리의 루트(package.json 옆)에 next.config.js 또는 next.config.mjs 파일을 만들 수 있습니다.
next.config.js는 JSON 파일이 아닌 일반 Node.js 모듈입니다.
Next.js 서버 및 빌드 단계에서 사용되며 클라이언트 빌드에는 포함되지 않습니다.
source
: String
destination
: String
permanent
: boolean
basepath
: false | undefinedlocale
: false | undefinedhas
: { type, key, value } []// next.config.js
module.exports = {
async redirects() {
return [
{
source: '/about',
destination: '/',
permanent: false,
},
{
source: '/detail/:id'',
destination: '/detail',
permanent: false,
},
]
},
}