Next.js Discord

Discord Forum

Application error: Client Side Exception when clicking the Link on the Not Found Page

Jenn posted this in #help-forum
Open in Discord
Also in:

I encountered a problem where if I put a Link on the not found page, clicking the link will show this on the screen: Application error: a client-side exception has occurred (see the browser console for more information). This error only shows up for those unauthenticated users. No error shows for those who are authenticated. Any idea what is wrong with the application?

Github repo:

export async function middleware(req: NextRequest) {
  const res =
  const supabase = createMiddlewareClient({ req, res })

  const {
    data: { user },
  } = await supabase.auth.getUser()

  // if user is not signed in and the current path is not /login redirect the user to /
  if (!user && req.nextUrl.pathname !== '/login') {
    return NextResponse.redirect(new URL('/', req.url))

  return res

export const config = {
  matcher: ['/water_station:path', '/waterTypes:path',],

0 Replies