title: Get token set on API on a SSR page Nextjs
body: <p>I am using Spotify authentication and in the callback I set the cookie and redirect to another page:</p>
  <pre class="lang-js prettyprint-override"><code>export default async (req, res) =&gt; {
    const token = await getToken(req.query.code);
  
    res.setHeader('Set-Cookie', cookie.serialize('token', JSON.stringify(token), {
      httpOnly: true,
      secure: process.env.NODE_ENV === 'production',
      maxAge: token.expires_in,
      sameSite: 'strict',
      path: '/',
    }));
  
    res.redirect(token ? '/cloner' : '/');
  }
  </code></pre>
  <p>On <code>'/cloner'</code> page I do SSR where <code>'/'</code> is the path to the login page:</p>
  <pre class="lang-js prettyprint-override"><code>export async function getServerSideProps(ctx) {
    const cookies = nookies.get(ctx);
  
    if (!cookies.token) { // &lt;-- is undefined
      return {
        redirect: {
          destination: '/',
          permanent: false,
        }
      }
    }
  
    return {
      props: {}
    }
  
  }
  </code></pre>
  <p>In the <code>getServerSideProps</code> the <code>token</code> is undefined so is returning me to the login page (<code>'/'</code>).</p>
  <p>BUUUUUUT, if I check in the site I can see the cookie, and if I write the <code>/cloner</code> manually that page load just right.</p>
  <p>If you check in the link below you will see that if you login redirect to login again. But, if you refresh the login page it sends you to the cloner page (in login I have also SSR to redirect to cloner if already login)</p>
  <p><a href="https://playlist-cloner.vercel.app/" rel="nofollow noreferrer">https://playlist-cloner.vercel.app/</a></p>