NextAuth not returning full response body
Unanswered
Barbary Lion posted this in #help-forum
Barbary LionOP
Im using nextauthjs with discord provider and im issuing a problem where when i try to edit the response body on the server to then send it to the client for some reason it gets truncated
import { AuthOptions } from "next-auth";
import DiscordProvider from "next-auth/providers/discord";
const scopes = ["identify", "email"];
const admins = ["jessieodeh14@gmail.com"];
export const options = {
// Configure one or more authentication providers
providers: [
DiscordProvider({
clientId: process.env.DISCORD_CLIENT_ID!,
clientSecret: process.env.DISCORD_CLIENT_SECRET!,
authorization: { params: { scope: scopes.join(" ") } },
profile(profile) {
const userRole = admins.includes(profile.email!) ? "admin" : "user";
console.log(profile);
return { ...profile, role: userRole };
},
}),
],
secret: process.env.JWT_SECRET!,
callbacks: {
async jwt({ token, user }) {
if (user) token.role = user.role;
return token;
},
async session({ session, token }) {
if (session.user) session.user.role = token.role;
return session;
},
},
} as AuthOptions;3 Replies
Barbary LionOP
with modifying response
without
i have done some testing and just including the profile function breaks the whole user object