Currently, I am in the process of developing my application using Next.js and implementing providers with next-auth. Everything runs smoothly when I use "npm run dev", however, I encounter an error when I switch to "npm run build". Here is a screenshot of the error: https://i.sstatic.net/0c29X.png
In order to handle authentication properly, I have set the variable NEXTAUTH_URL = localhost:3000 in a .env.local file.
The issue arises specifically when the function "getProviders()" is called from a file similar to this:
import {getProviders, useSession} from 'next-auth/client'
import Layout from "../components/layout";
export default function Page({providers}) {
const [session, loading] = useSession()
return (
<Layout providers={providers}>Page index</Layout>
)
}
export async function getStaticProps() {
const providers = await getProviders()
return {
props: {providers}
}
}