Skip to content

Commit

Permalink
feat: add next.js middleware with Clerk
Browse files Browse the repository at this point in the history
  • Loading branch information
ixartz committed Aug 10, 2023
1 parent 470731b commit 2f4a1d3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
1 change: 0 additions & 1 deletion next.config.js
Expand Up @@ -8,7 +8,6 @@ module.exports = withBundleAnalyzer({
dirs: ['.'],
},
poweredByHeader: false,
trailingSlash: true,
basePath: '',
// The starter code load resources from `public` folder with `router.basePath` in React components.
// So, the source code is "basePath-ready".
Expand Down
16 changes: 16 additions & 0 deletions src/app/(auth)/dashboard/layout.tsx
@@ -1,3 +1,4 @@
import { SignedOut } from '@clerk/nextjs';
import Link from 'next/link';

import { AppConfig } from '@/utils/AppConfig';
Expand Down Expand Up @@ -39,6 +40,21 @@ export default function DashboardLayout({
</li>
</ul>
</nav>

<nav>
<ul className="flex flex-wrap text-xl">
<li className="mr-6">
<SignedOut>
<Link
href="/"
className="border-none text-gray-700 hover:text-gray-900"
>
Sign out
</Link>
</SignedOut>
</li>
</ul>
</nav>
</div>
</header>

Expand Down
9 changes: 9 additions & 0 deletions src/middleware.ts
@@ -0,0 +1,9 @@
import { authMiddleware } from '@clerk/nextjs';

export default authMiddleware({
publicRoutes: '/(.*)',
});

export const config = {
matcher: ['/((?!.*\\..*|_next).*)', '/', '/(api|trpc)(.*)'],
};

0 comments on commit 2f4a1d3

Please sign in to comment.