Last active
May 4, 2024 15:24
-
-
Save balazsorban44/18667ad0d7daf393eaeedb55da702470 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { withAuth } from "next-auth/middleware"; | |
export default withAuth( | |
function middleware(request) { | |
if (request.nextUrl.pathname !== "/") return; | |
return Response.redirect(new URL("/home", request.url)); | |
}, | |
// This is NextAuth.js | |
// Docs: https://next-auth.js.org/configuration/nextjs#pages | |
// Needs to be the same as your `authOptions.pages` | |
{ pages: { signIn: "/login" } } | |
); | |
// This is Next.js | |
// Docs: https://nextjs.org/docs/app/building-your-application/routing/middleware#matcher | |
export const config = { | |
matcher: ["/((?!login).*)"], | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment