Next.js Discord

Discord Forum

Type error in Next Auth provider

Answered
Black Scoter posted this in #help-forum
Open in Discord
Black ScoterOP
Hi guys,
i was trying to build my project but i get this error:
Answered by Gouty oak gall
Your environment variables could be undefined, so TypeScript is complaining.
Change:
- process.env.DISCORD_ CLIENT_ID to process.env.DISCORD_ CLIENT_ID as string
- process.env.DISCORD_CLIENT_SECRET to process.env.DISCORD_CLIENT_SECRET as string

Also check out: https://env.t3.gg/docs/nextjs
View full answer

13 Replies

Black ScoterOP
thats my types file
Gouty oak gall
Your environment variables could be undefined, so TypeScript is complaining.
Change:
- process.env.DISCORD_ CLIENT_ID to process.env.DISCORD_ CLIENT_ID as string
- process.env.DISCORD_CLIENT_SECRET to process.env.DISCORD_CLIENT_SECRET as string

Also check out: https://env.t3.gg/docs/nextjs
Answer
Black ScoterOP
thanks
Argument of type '{ clientId: string; clientSecret: string; callbackUrl: string | undefined; token: string; userinfo: string; authorization: { params: { scope: string; }; }; }' is not assignable to parameter of type 'OAuthUserConfig<any>'.
Object literal may only specify known properties, and 'callbackUrl' does not exist in type 'OAuthUserConfig<any>'.ts(2345)
you can also just add ! to the end
process.env.DISCORD_CLIENT_ID!
process.env.DISCORD_CLIENT_SECRET! process.env.DISCORD_CLIENT_SECRET!
@Black Scoter and for the callbackurl?
but do the same thing that you did for the other 2 for this one
@riský but do the same thing that you did for the other 2 for this one
Black ScoterOP
i've tried but i still get the same error:
Type error: Argument of type '{ clientId: string; clientSecret: string; callbackUrl: string; token: string; userinfo: string; authorization: { params: { scope: string; }; }; }' is not assignable to parameter of type 'OAuthUserConfig<any>'.
Object literal may only specify known properties, and 'callbackUrl' does not exist in type 'OAuthUserConfig<any>'.
ahh callbackurl isn't an option...
Black ScoterOP
oh lol, sorry
yeah because the callback is done automatically by nextauth
and have you added the callback of the folowing to your discord redirects section for the app:
http://localhost:3000/api/auth/callback/discord (and change the domain for your actual domains too)