mirror of
https://github.com/SrIzan10/helium.git
synced 2026-06-06 00:56:58 +00:00
15 lines
592 B
TypeScript
15 lines
592 B
TypeScript
// source: https://clerk.com/docs/guides/secure/protect-pages
|
|
// Define the routes you want to protect with `createRouteMatcher()`
|
|
const isProtectedRoute = createRouteMatcher(["/presets(.*)", "/stream(.*)"]);
|
|
|
|
export default defineNuxtRouteMiddleware((to) => {
|
|
// Use the `useAuth()` composable to access the `isSignedIn` property
|
|
const { isSignedIn } = useAuth();
|
|
|
|
// Check if the user is not signed in and is trying to access a protected route
|
|
// If so, redirect them to the sign-in page
|
|
if (!isSignedIn.value && isProtectedRoute(to)) {
|
|
return navigateTo("/sign-in");
|
|
}
|
|
});
|