How can I render server-side with Next.js, Apollo Client, and MongoDB Atlas GraphQL API?

I’m following along with this guide in the MongoDB docs to get server-side rendering working with a Next.js app. I’ve copied things pretty much verbatim but I’m so far unable to get it working. I keep getting back a 401 (unauthorised response) saying the access token has expired in the console:

statusCode: 401,
result: {
  error: 'invalid session: access token expired',
  error_code: 'InvalidSession',

And from the Atlas logs I see:

Error: unauthorized
Logs: ["token contains an invalid number of segments"]

In my browser console I can see that the cookie is created:

I’ve also setup a StackBlitz here to show my code in full (although .env variables haven’t been included).

Can anyone suggest what I am missing or doing wrong?