Estou recebendo pelo token uma foto em jwt que nao esta renderizando
Ferramentas usadas: nextjs, typescript, next-auth, keycloak, LDAP
A imagen vem do LDAP vai para o usuário do keycloak e a minha aplicacao se encarrega de armazenar o token jwt apos a autenticacao, mas quando um usuario que tem foto a aplicacao da erro 431
codigo do next auth:
import { get, maxHeaderSize } from "http";
import { NextAuthOptions } from "next-auth"
import KeycloakProvider from "next-auth/providers/keycloak";
import { setGlobal } from "next/dist/trace";
export const authOptions: NextAuthOptions = {
providers: [
KeycloakProvider({
clientId: process.env.KC_CLIENT_ID,
clientSecret: process.env.KC_CLIENT_SECRET,
issuer: process.env.KC_ISSUER,
})
],
callbacks: {
// Servidor
jwt: async ({ token, user, profile }) => {
const customUser = profile as unknown as any
console.log(setGlobal(maxHeaderSize, 1000))
if (user) {
return {
...token,
newemail: customUser.mailPrimaryAddress,
company: customUser.company,
group: customUser.group,
jpegPhoto: customUser.jpegPhoto
}
}
return token
},
// Cliente
session: async ({ session, token }) => {
return {
...session,
user: {
// ...token
// newemail: token.newemail
name: token.name,
email: token.email,
// // PROPS CRIADAS
// company: token.company,
// group: token.group,
// jpegPhoto: token.jpegPhoto,
}
}
},
},
events: {
async signOut() {
await get(ENV)
}
}
}
middleware:
import { NextAuthMiddlewareOptions, NextRequestWithAuth, withAuth } from "next-auth/middleware"
import { NextResponse } from "next/server"
const middleware = (request:NextRequestWithAuth) =>{
console.log("[MIDDLEWARE_NEXTAUTH_TOKEN]: ", request.nextauth.token)
const isPrivateRoutes = request.nextUrl.pathname.startsWith("/private/admin")
const isAdminUser = request.nextauth.token?.group === 'admin'
if(isPrivateRoutes && !isAdminUser){
return NextResponse.rewrite(new URL('/denied', request.url))
}
}
const callbackOptions:NextAuthMiddlewareOptions = {}
export default withAuth(middleware,callbackOptions)
export const config ={
matcher: ['/private/:path*']
};
Agradeço a ajuda desde ja!!! Estou aceitando dicas e sugestões!