Skip to content
Discussion options

You must be logged in to vote

The same thing happens to me also. But for some reason only if I add a call to getSessionUser inside the middleware function and then restart the developer server.

middleware.ts (inside of the root folder)

// 1. Ignore certain paths
export const config = {
	matcher: ["/((?!api|_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt).*)"],
};

export default async function middleware(req: NextRequest) {
	// 2. Get the currently logged in user
	const user = await getSessionUser();

	// 3. Redirect
	if (user) {
		if (sharedPages.some((page) => page.path === req.nextUrl.pathname)) return NextResponse.rewrite(new URL("/private/shared" + req.nextUrl.pathname, req.nextUrl));

		switch (user.t…

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by IlamathiIla
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
5 participants