fix: authed

This commit is contained in:
Aslam H
2024-10-08 13:55:36 +07:00
parent 1ed8d39207
commit 7c31f9b417
4 changed files with 120 additions and 111 deletions

View File

@@ -1,13 +1,20 @@
/// <reference types="vite/client" />
import { getAuth } from "@clerk/tanstack-start/server"
import type { QueryClient } from "@tanstack/react-query"
import {
Outlet,
ScrollRestoration,
createRootRouteWithContext,
} from "@tanstack/react-router"
import { Body, Head, Html, Meta, Scripts } from "@tanstack/start"
import {
Body,
createServerFn,
Head,
Html,
Meta,
Scripts,
} from "@tanstack/start"
import * as React from "react"
import { fetchClerkAuth } from "~/actions"
import { DefaultCatchBoundary } from "~/components/DefaultCatchBoundary.js"
import { NotFound } from "~/components/NotFound.js"
import appCss from "~/styles/app.css?url"
@@ -25,11 +32,17 @@ export const ReactQueryDevtools =
process.env.NODE_ENV === "production"
? () => null
: React.lazy(() =>
import("@tanstack/react-query-devtools/production").then((d) => ({
import("@tanstack/react-query-devtools").then((d) => ({
default: d.ReactQueryDevtools,
})),
)
export const fetchClerkAuth = createServerFn("GET", async (_, ctx) => {
const auth = await getAuth(ctx.request)
return auth
})
export const Route = createRootRouteWithContext<{
queryClient: QueryClient
}>()({