NextAuth Problem
Unanswered
Oriental chestnut gall wasp posted this in #help-forum
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
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 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)
Please don't share your secret. Now you need to generate new secret and make sure to invalidate your now public secrets
@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?
@B33fb0n3 Please don't share your secret. Now you need to generate new secret and make sure to invalidate your now public secrets
Oriental chestnut gall waspOP
Will do it
@Oriental chestnut gall wasp where can I find this?
it#s called
There should be only one
route.jsThere should be only one
@Oriental chestnut gall wasp 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)
Oriental chestnut gall waspOP
this is the route.js
@Oriental chestnut gall wasp this is the route.js
make sure to follow instructions, that I gave you: https://nextjs-forum.com/post/1333825441362083861#message-1333825981110030407
Your route.js should look like this[:](https://cdn.discordapp.com/attachments/1333825441362083861/1333825980841590816/thefileusearchedfor.png?ex=679a4dbf&is=6798fc3f&hm=c915af1724afa6b30e6b9d2b6b8cb07d886a16897c472b9c6d63570e38141938&)
You may need to change your imports
Your route.js should look like this[:](https://cdn.discordapp.com/attachments/1333825441362083861/1333825980841590816/thefileusearchedfor.png?ex=679a4dbf&is=6798fc3f&hm=c915af1724afa6b30e6b9d2b6b8cb07d886a16897c472b9c6d63570e38141938&)
You may need to change your imports
@B33fb0n3 make sure to follow instructions, that I gave you: https://discord.com/channels/752553802359505017/1333825441362083861/1333825981110030407
Your route.js should look like this[:](https://cdn.discordapp.com/attachments/1333825441362083861/1333825980841590816/thefileusearchedfor.png?ex=679a4dbf&is=6798fc3f&hm=c915af1724afa6b30e6b9d2b6b8cb07d886a16897c472b9c6d63570e38141938&)
You may need to change your imports
Oriental chestnut gall waspOP
do you have the @/lib/auth?
@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
Please do not share your secrets
auth.js and put your auth options in there. Then change your importPlease 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?