production ready
This commit is contained in:
+4
-1
@@ -1,5 +1,6 @@
|
||||
import { redirect, type Handle } from '@sveltejs/kit';
|
||||
import { sequence } from '@sveltejs/kit/hooks';
|
||||
import { PUBLIC_CONVEX_URL } from '$env/static/public';
|
||||
import {
|
||||
createConvexAuthHooks,
|
||||
createRouteMatcher
|
||||
@@ -10,7 +11,9 @@ const isProtectedRoute = createRouteMatcher([
|
||||
'/entries{/*rest}',
|
||||
'/settings{/*rest}'
|
||||
]);
|
||||
const { handleAuth, isAuthenticated } = createConvexAuthHooks();
|
||||
const { handleAuth, isAuthenticated } = createConvexAuthHooks({
|
||||
convexUrl: PUBLIC_CONVEX_URL
|
||||
});
|
||||
|
||||
const protectRoutes: Handle = async ({ event, resolve }) => {
|
||||
if (isProtectedRoute(event.url.pathname) && !(await isAuthenticated(event))) {
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import { PUBLIC_CONVEX_URL } from '$env/static/public';
|
||||
import { createConvexAuthHandlers } from '@mmailaender/convex-auth-svelte/sveltekit/server';
|
||||
import type { LayoutServerLoad } from './$types.js';
|
||||
|
||||
const { getAuthState } = createConvexAuthHandlers();
|
||||
const { getAuthState } = createConvexAuthHandlers({
|
||||
convexUrl: PUBLIC_CONVEX_URL
|
||||
});
|
||||
|
||||
export const load: LayoutServerLoad = async (event) => {
|
||||
return {
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import { PUBLIC_CONVEX_URL } from '$env/static/public';
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
import { createConvexAuthHandlers } from '@mmailaender/convex-auth-svelte/sveltekit/server';
|
||||
import type { PageServerLoad } from './$types.js';
|
||||
|
||||
const { isAuthenticated } = createConvexAuthHandlers();
|
||||
const { isAuthenticated } = createConvexAuthHandlers({
|
||||
convexUrl: PUBLIC_CONVEX_URL
|
||||
});
|
||||
|
||||
export const load: PageServerLoad = async (event) => {
|
||||
throw redirect(302, (await isAuthenticated(event)) ? '/dashboard' : '/signin');
|
||||
|
||||
Reference in New Issue
Block a user