Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

226
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda