Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

227
Visualizações
How to check the jwt and next-auth in the same midellware in next js

I have an application with next-auth and a simple login with jwt but when i use the middleware in next js to check the next-auth's session is exists , but what if the user log in with the simple login (username & pwd ) , i try to store my jwt from the simple login in cookies but the middleware is in the backend and it can't connect to the frontend , here is my middleware

import {NextResponse} from "next/server";

export async function middleware(req) {

        let token = await getToken({req,secret: process.env.NEXTAUTH_SECRET})

        let {pathname}  = req.nextUrl;
        
        if(pathname.includes("/api/auth") || token) return NextResponse.next();
        
        if( !token && pathname !== "/login") return NextResponse.redirect(`${process.env.NEXTAUTH_URL}/login`); // if there is no jwt or token or the user not comming from /login then redirect him to /login

}

How can i check the jwt token from the simple log in and the token from next-auth in the same middleware because when i try to log in with the simple it's not redirect me to the the homeenter image description here

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda