Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: correct integrating with clerk #1754

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

willx12123
Copy link

@willx12123 willx12123 commented Feb 28, 2025

  1. change protect usage to latest version
  2. add locale prefix matcher and non locale prefix matcher at the same time to avoid infinite redirect

Fixes #1458

1. change `protect` usage to latest version
2. add locale prefix matcher and non locale prefix matcher at the same time to avoid infinite redirect
Copy link
Owner

@amannn amannn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome thanks!

@@ -263,10 +263,10 @@ import {routing} from './i18n/routing';

const handleI18nRouting = createMiddleware(routing);

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why this is necessary? The example currently is based on localePrefix: 'always' since it's the default. Why is there a necessity to match /dashboard/…?

export default clerkMiddleware((auth, req) => {
if (isProtectedRoute(req)) auth().protect();
export default clerkMiddleware(async (auth, req) => {
if (isProtectedRoute(req)) await auth.protect();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you upgrade the version number below the snippet?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Docs]: Update Clerk example
2 participants