Next.js Discord

Discord Forum

Error Handling for External Links and Pages Outside Next.js Application Structure

Unanswered
English Lop posted this in #help-forum
Open in Discord
English LopOP
When setting links outside of pages within a Next.js application using pathname format, the following error occurs:
Error: Failed to lookup route: /
// or 
Error: Failed to lookup route: /{pathname}


I'm using a shared Link component and I'm dealing with both external links (in pathname format) and links to pages within the Next.js application.

// nextjs version v12.3.2
import Link from 'next/link'
// Example:
<Link href="/"/> // For instance: www.next.com 


After encountering an error because the page doesn't exist within the application, it redirects to that page.
If anyone has resolved this issue before, I would appreciate it if you could share the solution. Thank you🙇🏻‍♂️

1 Reply

English LopOP
※Additionally, the application is managed in a different environment where the index.ts within the pages/ directory is not present