title: NextJs Redirects if there is no cookie
body: <p>I want to redirect to /login page in /profile page if there is no token cookie. Here is my code:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>module.exports = {
    async redirects() {
      return [
        {
          source: '/profile',
          has: [
            {
              type: "cookie",
              key: "token",
              value: "undefined"
            }
          ],
          permanent: false,
          destination: '/login',
        },
      ]
    },
  }</code></pre>
  </div>
  </div>
  </p>