-
Notifications
You must be signed in to change notification settings - Fork 2
Upgrade to v5 #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
| export default clerkMiddleware(async (auth, req) => { | ||
| if (req.nextUrl.pathname === "/dashboard" && !auth().userId) { | ||
| auth().protect(); | ||
|
|
||
| return NextResponse.next(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets encourage the use of the pattern matcher helper.
| export default clerkMiddleware(async (auth, req) => { | |
| if (req.nextUrl.pathname === "/dashboard" && !auth().userId) { | |
| auth().protect(); | |
| return NextResponse.next(); | |
| } | |
| const isProtectedRoute = createRouteMatcher(['dashboard/(.*)']); | |
| export default clerkMiddleware(async (auth, req) => { | |
| if (isProtectedRoute(req) && !auth().userId) { | |
| auth().protect(); | |
| return NextResponse.next(); | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch, oddly I believe in other places I was doing just that so idk why i did this lol
… to middleware to protect the dashboard
JacobMGEvans
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tentative to the question but non-blocking
|
|
||
| export default clerkMiddleware(async (auth, req) => { | ||
| if (isProtectedDashboardRoute(req) && !auth().userId) { | ||
| auth().protect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be:
| auth().protect(); | |
| return auth().protect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did we find out if its necessary to return the protect function?
|
can't see either demo site for pages or app implentations |
Changes:
authMiddlewarewithclerkMiddlewareand protected the/dashboardrouteauthto the new server import from@clerk/nextjs/server