Skip to content

Commit

Permalink
feat: make dashboard without lang protected route in Clerk
Browse files Browse the repository at this point in the history
  • Loading branch information
ixartz committed May 7, 2024
1 parent c1978f1 commit 704466b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .env
Expand Up @@ -15,6 +15,8 @@ DATABASE_URL=file:next-js-boilerplate.db
# Clerk authentication
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_b3Blbi1zdGlua2J1Zy04LmNsZXJrLmFjY291bnRzLmRldiQ

NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in

######## [BEGIN] SENSITIVE DATA ######## For security reason, don't update the following variables (secret key) directly in this file.
######## Please create a new file named `.env.local`, all environment files ending with `.local` won't be tracked by Git.
######## After creating the file, you can add the following variables.
Expand Down
8 changes: 0 additions & 8 deletions README.md
Expand Up @@ -399,14 +399,6 @@ npm run db:studio

Then, you can open https://local.drizzle.studio with your favorite browser to explore your database.

### Known warnings

#### webpack.cache.PackFileCacheStrategy

Warning: webpack.cache.PackFileCacheStrategy Serializing big strings (104kiB) impacts deserialization performance (consider using Buffer instead and decode when needed)

This warning is caused by using `Clerk` and `next-intl` middlewares. It only happens when both middlewares are used together.

### VSCode information (optional)

If you are VSCode users, you can have a better integration with VSCode by installing the suggested extension in `.vscode/extension.json`. The starter code comes up with Settings for a seamless integration with VSCode. The Debug configuration is also provided for frontend and backend debugging experience.
Expand Down
5 changes: 4 additions & 1 deletion src/middleware.ts
Expand Up @@ -9,7 +9,10 @@ const intlMiddleware = createMiddleware({
defaultLocale: AppConfig.defaultLocale,
});

const isProtectedRoute = createRouteMatcher(['/:locale/dashboard(.*)']);
const isProtectedRoute = createRouteMatcher([
'/dashboard(.*)',
'/:locale/dashboard(.*)',
]);

export default clerkMiddleware((auth, req) => {
if (isProtectedRoute(req)) auth().protect();
Expand Down

0 comments on commit 704466b

Please sign in to comment.