Skip to content

Conversation

@domitriusclark
Copy link
Contributor

Changes:

  • upgraded to v5 Canary (until we cut a full release)
  • removed all SVG errors in the terminal
  • added missing Next SVG
  • replaced authMiddleware with clerkMiddleware and protected the /dashboard route
  • removed the empty api directory
  • upgraded all packages to latest
  • updated the import path for auth to the new server import from @clerk/nextjs/server

@vercel
Copy link

vercel bot commented Jan 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
clerk-nextjs-demo-pages-router ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 19, 2024 4:51pm

Comment on lines 4 to 9
export default clerkMiddleware(async (auth, req) => {
if (req.nextUrl.pathname === "/dashboard" && !auth().userId) {
auth().protect();

return NextResponse.next();
}

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.

Suggested change
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();
}

Copy link
Contributor Author

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

Copy link

@JacobMGEvans JacobMGEvans left a 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();

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:

Suggested change
auth().protect();
return auth().protect();

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?

@collinboler
Copy link

can't see either demo site for pages or app implentations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants