Next.js Discord

Discord Forum

NextAuth Problem

Unanswered
Oriental chestnut gall wasp posted this in #help-forum
Open in Discord
Oriental chestnut gall waspOP
Hello I want to use nextauth, but if I use signIn("discord") I will directly route to this page.

25 Replies

@Oriental chestnut gall wasp Hello I want to use nextauth, but if I use signIn("discord") I will directly route to this page.
the docs from next-auth are pretty shitty for setting up next-auth. Your auth route handler need to look like this: (see attached).
Make sure to change from .ts to .js as you are using .js.
@B33fb0n3 the docs from next-auth are pretty shitty for setting up next-auth. Your auth route handler need to look like this: (see attached). Make sure to change from .ts to .js as you are using .js.
Oriental chestnut gall waspOP
Now it look like this
@Oriental chestnut gall wasp Now it look like this
please share your authOptions
Oriental chestnut gall waspOP
import NextAuth from "next-auth"
import DiscordProvider from "next-auth/providers/discord";

export const authOptions = {
  providers: [
    DiscordProvider({
        clientId: "1333780281097715833",
        clientSecret: "BkrNbJflOFu6Izvx8ROfKidJFqDN80-3"
    })
  ]
}

export default NextAuth(authOptions)
this ist in my console
Oh I forget to ad handlers
Now I get this @B33fb0n3
@Oriental chestnut gall wasp Now I get this <@301376057326567425>
Can you share your route handler?
@B33fb0n3 Can you share your route handler?
Oriental chestnut gall waspOP
where can I find this?
@Oriental chestnut gall wasp where can I find this?
it#s called route.js
There should be only one
@Oriental chestnut gall wasp do you have the @/lib/auth?
You may need to change your imports
Oriental chestnut gall waspOP
the route looks correctly I think
@Oriental chestnut gall wasp the route looks correctly I think
you need to create another file. Call it auth.js and put your auth options in there. Then change your import

Please do not share your secrets
@B33fb0n3 you need to create another file. Call it auth.js and put your auth options in there. Then change your import Please **do not** share your secrets
Oriental chestnut gall waspOP
import NextAuth from "next-auth"

import { authOptions } from "./auth";

const handler = NextAuth(authOptions)
export { handler as GET, handler as POST}
auth.js:
import DiscordProvider from "next-auth/providers/discord";

export const authOptions = {
  providers: [
    DiscordProvider({
        clientId: "",
        clientSecret: ""
    })
  ]
}
but same error
@Oriental chestnut gall wasp can you create a repro, for example via github or https://codesandbox.io/ ?
@Oriental chestnut gall wasp?