Open mshabb opened 6 months ago
same problem
I found out that it is due to the middleware.ts
file
Here is the right middleware.ts
file to have with Next.js 14
import {withAuth} from "@kinde-oss/kinde-auth-nextjs/middleware";
export const config = {
matcher: ["/dashboard/:path*", "/auth-callback"]
}
export default withAuth
After loggin in, the home page is getting displayed instead of the dashboard. Also, none of the links to the dashboard is working.
Here is my Dashboard file.
'use client'
import { trpc } from '@/app/_trpc/client' import UploadButton from './UploadButton' import { Ghost, Loader2, MessageSquare, Plus, Trash, } from 'lucide-react' import Skeleton from 'react-loading-skeleton' import Link from 'next/link' import { format } from 'date-fns' import { Button } from './ui/button' import { useState } from 'react' import { getUserSubscriptionPlan } from '@/lib/stripe'
interface PageProps { subscriptionPlan: Awaited<ReturnType>
}
const Dashboard = ({subscriptionPlan}: PageProps) => {
const [currentlyDeletingFile, setCurrentlyDeletingFile] = useState<string | null>(null)
const utils = trpc.useUtils()
const { data: files, isLoading } = trpc.getUserFiles.useQuery()
const { mutate: deleteFile } = trpc.deleteFile.useMutation({ onSuccess: () => { utils.getUserFiles.invalidate() }, onMutate({ id }) { setCurrentlyDeletingFile(id) }, onSettled() { setCurrentlyDeletingFile(null) }, } )
return (
My Files
{files .sort( (a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime() ) .map((file) => (-
{format(
new Date(file.createdAt),
'MMM yyyy'
)}
mocked
))}
) : isLoading ? ({file.name}
Pretty empty around here
Let's upload your first PDF.
) }
export default Dashboard