title: Next JS Middlewares - URLs is malformed. Please use only absolute URLs
body: <p>This is the code in my <code>_middleware</code> file located in the <code>pages</code> folder it keeps giving me the URL malformed error anytime a request is sent:</p>
  <pre><code>const token = await getToken({req,secret:process.env.JWT_SECRET});
  
  const {pathname, origin} = req.nextUrl;
  
  if(pathname?.includes('/api/auth') || token){
      return NextResponse.next();
  };
  
  if (!token &amp;&amp; pathname !== &quot;/login&quot;) {
      return NextResponse.redirect(&quot;/login&quot;);
  }
  </code></pre>