Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

protectedPaths not protecting routes with hyphens #67

Open
GodTamIt opened this issue Jul 6, 2024 · 3 comments
Open

protectedPaths not protecting routes with hyphens #67

GodTamIt opened this issue Jul 6, 2024 · 3 comments

Comments

@GodTamIt
Copy link

GodTamIt commented Jul 6, 2024

It seems that protectedRoutes does not seem to work with routes that contain hyphens.

For example, this seems to protect the /create route:

export const handle: Handle = sequence(
	handleClerk(CLERK_SECRET_KEY, {
		debug: true,
		protectedPaths: ['/create'],
		signInUrl: '/sign-in'
	})
);

However, this fails to protect the /create-entity route:

export const handle: Handle = sequence(
	handleClerk(CLERK_SECRET_KEY, {
		debug: true,
		protectedPaths: ['/create-entity'],
		signInUrl: '/sign-in'
	})
);
@GodTamIt GodTamIt changed the title protectedRoutes not protecting routes with hyphens protectedPaths not protecting routes with hyphens Jul 6, 2024
@pensono
Copy link

pensono commented Jul 30, 2024

This feels like the correct behavior to me- it's comparing path segments rather than the string of the whole path

@GodTamIt
Copy link
Author

@pensono hmm, I'm a bit confused then. How would one protect a path named /create-entity then? Or is that not possible?

@pensono
Copy link

pensono commented Aug 1, 2024

@GodTamIt Would either of these work?

	handleClerk(CLERK_SECRET_KEY, {
		// ...
		protectedPaths: ['/create-entity', '/create-other-entity'],
	})

or

	handleClerk(CLERK_SECRET_KEY, {
		// ...
		protectedPaths: [
			(event) => event.route.id != null && !event.route.id.startsWith('/create-')
		],
	})

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

No branches or pull requests

2 participants