leerob / site

My site built with Next.js, Tailwind, and Vercel.
https://leerob.com
7.2k stars 1.39k forks source link

The guestbook appeared [CLIENT_FETCH_ERROR] when the vercel were deployed #623

Closed lyratu closed 1 year ago

lyratu commented 1 year ago

Error occurs when I submit information to guestbook

Snipaste_2023-06-10_16-58-22

![Snipaste_2023-06-10_16-58-22](https://github.com/leerob/leerob.io/assets/24313098/08a367e8-da26-42db-87c5-388141c881af)
[next-auth][error][CLIENT_FETCH_ERROR] 
https://next-auth.js.org/errors#client_fetch_error undefined {
  error: {},
  url: 'https://tulw.top/api/auth/session',
  message: undefined
}

But it doesn't appear for me in local development mode.


It is okay when I modify the code to be deployed as follows:

image

import { authOptions } from 'pages/api/auth/[...nextauth]'
import { getServerSession } from "next-auth/next"

export default async function handler(
  req: NextApiRequest,
  res: NextApiResponse
) {
  const session = await getServerSession(req, res, authOptions)
  ...
}