import NextAuth, { AuthOptions } from "next-auth"
import CredentialsProvider from "next-auth/providers/credentials"
export const authOptions:AuthOptions = {providers: [
CredentialsProvider({
name: 'Credentials',
credentials: {
username: { label: "Username", type: "text", placeholder: "jsmith" },
password: { label: "Password", type: "password" }
},
async authorize(credentials, req) {
const res = await fetch("/api/user", {
method: 'POST',
body: JSON.stringify(credentials),
headers: { "Content-Type": "application/json" }
})
const user = await res.json()
if (res.status===200 && user) {
return user
}
return null
}
})
],
//secret: `lhc6tiqPum3VlZrv/BT7LRe9jHA/TGWYztBETtmj2IY=`,
secret: process.env.NEXTAUTH_SECRET,
}
const handler = NextAuth(authOptions)
export { handler as GET, handler as POST }
tried both ways, directly injecting a secret in route.ts as well as optimally using NEXTAUTH_SECRET env var but still getting errors.