본문 바로가기
카테고리 없음

next redirect

by 멈추지않아 2022. 3. 25.

redirect에대해서 알아보겠습니다.

next.confg.js 열어주시고

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  async redirects() {
    return [
      {
        source: "/test",
        destination: "/ack",
        permanent: false,
      },
    ];
  },
};

module.exports = nextConfig;

작성

source: "/test",
 destination: "/ack",
permanent: false,
이 세가지만 우리가 조종할 것입니다 나머지는 변경되면 제대로 동작이 안되요
source는 어떤 주소가 들어오면 작동할것인지
desination  어느주소로 redirect할것인지
permanent 정보를 보전할것인지 아닌지

 

이세가지만 설정하고  서버를 다시 시작해주시고 보면

test를 쳤지만 ack페이지로 이동한것을 확인할수 있습니다.