Next.js CORS에러 간단 해결

0

React

목록 보기
9/9

공부 중 다음카페 인기글 api를 가져오려는데 CORS에러가 발생했다.
검색 후 아래와 같이 next.config.js에 간단하게 작성해주니 문제가 해결되었다.

// next.config.js

const nextConfig = {
  ...
  async rewrites() {
    return [
      {
        source: "/daumcafe/:path*",
        destination: `https://top.cafe.daum.net/_c21_/api/v3/:path*`,
      },
    ];
  },
};

module.exports = nextConfig;
profile
를 질투하는 그냥 개발자입니다.

0개의 댓글