-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(examples): Updated to Clerk Core 2 (Clerk NextJS v5) (#704)
Updates the Clerk examples following https://clerk.com/docs/upgrade-guides/core-2/overview
- Loading branch information
1 parent
0cafdbe
commit 9049bad
Showing
9 changed files
with
1,357 additions
and
1,763 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,19 @@ | ||
import { authMiddleware } from "@clerk/nextjs"; | ||
import { clerkMiddleware, createRouteMatcher } from "@clerk/nextjs/server"; | ||
import { NextResponse } from "next/server"; | ||
|
||
export default authMiddleware({ | ||
// Routes that can be accessed while signed out | ||
publicRoutes: ["/", '/api/public'], | ||
apiRoutes: ["/api/private"], | ||
const isProtectedRoute = createRouteMatcher(["/api/private", "/api/token"]); | ||
|
||
export default clerkMiddleware((auth, request) => { | ||
if (isProtectedRoute(request)) { | ||
auth().protect(); | ||
} | ||
|
||
return NextResponse.next(); | ||
}); | ||
|
||
export const config = { | ||
// Protects all routes, including api/trpc. | ||
// See https://clerk.com/docs/references/nextjs/auth-middleware | ||
// See https://clerk.com/docs/references/nextjs/clerk-middleware | ||
// for more information about configuring your Middleware | ||
matcher: ["/((?!.+\\.[\\w]+$|_next).*)", "/", "/(api|trpc)(.*)"], | ||
}; |
Oops, something went wrong.