Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

133
Views
¿Puedo acceder al nombre de la ruta dinámica en el middleware next.js?

Tengo una ruta en /:username .

En mi archivo _middleware.ts me gustaría hacer algo como esto

 export function middleware(req: NextRequest) { const isDynamicRoute = req.nextUrl.pathname === "/[username]"; if (isDynamicRoute) { return undefined } // handle other routes... }

El problema es que parece que no puedo acceder a este nombre de ruta dinámica en el middleware. Veo /test como el nombre de ruta en lugar de /[username] .

Cuando registro la request , veo lo que estoy buscando, pero está dentro de una clave [Symbol(internal request)] (junto con una clave de símbolo separada que incluye el nombre de ruta real). ¿Es posible acceder a este valor de forma fiable en el archivo de middleware? ¿O necesito manejar esta lógica en _app.ts ? (ver registro abajo)

 [Symbol(internal request)]: { credentials: 'same-origin', headers: BaseHeaders [Headers] { [Symbol(map)]: [Object] }, method: 'GET', referrer: 'about:client', redirect: 'follow', url: NextURL { href: '/test', origin: '', protocol: '', username: '', password: '', host: '', hostname: '', port: '', pathname: '/test', search: '', searchParams: URLSearchParams {}, hash: '' } }, [Symbol(internal request)]: { cookieParser: [Function: cookieParser], geo: {}, ip: undefined, page: { name: '/[username]', params: [Object] }, url: NextURL { href: '/test', origin: '', protocol: '', username: '', password: '', host: '', hostname: '', port: '', pathname: '/test', search: '', searchParams: URLSearchParams {}, hash: '' } }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!