No secret | nextAuth
Answered
Naeemgg posted this in #help-forum
NaeemggOP
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.Answered by Naeemgg
I tried and tried and ended up making another next app and migrating current one to it and everything is good now
7 Replies
Are u generating the secret using openssl?
Also update to the latest nextauth. I literally cannot see why this wouldnt work otherwise tbh
NaeemggOP
Yes
And it was latest version
NaeemggOP
I tried and tried and ended up making another next app and migrating current one to it and everything is good now
Answer
NaeemggOP
Idk why it happened, what was it's cause
Irony is with local Dev and prod vercel logs were showing the same error