Application error: Client Side Exception when clicking the Link on the Not Found Page
Unanswered
Jenn posted this in #help-forum
JennOP
Also in: https://stackoverflow.com/questions/77407264/application-error-client-side-exception-when-clicking-the-link-on-the-not-found?noredirect=1#comment136487022_77407264
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: https://github.com/Jennelle186/NextJS-Supabase
Middleware.ts
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: https://github.com/Jennelle186/NextJS-Supabase
Middleware.ts
export async function middleware(req: NextRequest) {
const res = NextResponse.next()
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',],