#No secret | nextAuth

9 messages · Page 1 of 1 (latest)

left blaze
#
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.

ebon doveBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

ornate surge
#

Are u generating the secret using openssl?

#

Also update to the latest nextauth. I literally cannot see why this wouldnt work otherwise tbh

left blaze
#

I tried and tried and ended up making another next app and migrating current one to it and everything is good now

#

Idk why it happened, what was it's cause

#

Irony is with local Dev and prod vercel logs were showing the same error