When I attempt to sign in using next-auth in my Next.js app in production mode by running the command `yarn build && yarn start` on my local machine, the app fails. The error message displayed in the terminal is:
TypeError [ERR_INVALID_URL]: Invalid URL
at new NodeError (node:internal/errors:372:5)
at URL.onParseError (node:internal/url:553:9)
at new URL (node:internal/url:629:5)
at Object.redirect (/Users/name/Documents/GitHub/app/node_modules/next-auth/core/lib/default-callbacks.js:16:65)
at createCallbackUrl (/Users/name/Documents/GitHub/app/node_modules/next-auth/core/lib/callback-url.js:20:35)
at init (/Users/name/Documents/GitHub/app/node_modules/next-auth/core/init.js:132:48)
at AuthHandlerInternal (/Users/name/Documents/GitHub/app/node_modules/next-auth/core/index.js:98:28)
at AuthHandler (/Users/name/Documents/GitHub/app/node_modules/next-auth/core/index.js:335:34)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async NextAuthHandler (/Users/name/Documents/GitHub/app/node_modules/next-auth/next/index.js:38:20) {
input: 'undefined/home',
code: 'ERR_INVALID_URL'
}
The issue does not occur when running the app in development mode with the command `yarn dev`. Here is my [...nextauth].ts file:
[Add your unique rewrite here]
I have set the necessary environmental variables in .env.local and nothing has changed, so I'm puzzled by the different behavior in production. Any insights or suggestions?