Custom domains with Next.js & Vercel

When we set up custom domains after following the Next.js tutorial, everything works find locally and uses our custom domain correctly.

When we deploy to Vercel, we get really strange errors. We’ve triple checked, and all the environment variables are getting set correctly (AUTH0_ISSUER_BASE_URL, AUTH0_BASE_URL).

The errors are all JSON parsing errors, during the processing of the /callback endpoint on the server side. The errors are all “cannot parse JSON, unexpected character at position 0”, with a random character every time. Sometimes we also get an error during credential discovery, where it complains about not being able to parse the /.well-known/openid-configuration JSON with a similar error.

Do we need to set some other variable (like AUTH0_COOKIE_DOMAIN or something?). Any idea what could be causing this?