diff --git a/src/components/Dashboard.tsx b/src/components/Dashboard.tsx index f4f4250..2291bd0 100644 --- a/src/components/Dashboard.tsx +++ b/src/components/Dashboard.tsx @@ -17,7 +17,7 @@ interface PageProps { const Dashboard = ({ subscriptionPlan }: PageProps) => { const [currentlyDeletingFile, setCurrentlyDeletingFile] = useState(null) - const utils = trpc.useContext() + const utils = trpc.useUtils() const { data: files, isLoading } = trpc.getUserFiles.useQuery() diff --git a/src/components/LoginModal.tsx b/src/components/LoginModal.tsx index baf7b03..2393c2d 100644 --- a/src/components/LoginModal.tsx +++ b/src/components/LoginModal.tsx @@ -147,7 +147,7 @@ export default function LoginModal() { type="button" variant="outline" size="icon" - onClick={() => signIn('github')} + onClick={() => signIn('github', { callbackUrl: 'http://localhost:3000/bar' })} > diff --git a/src/components/Providers.tsx b/src/components/Providers.tsx index 86478d5..d1f633f 100644 --- a/src/components/Providers.tsx +++ b/src/components/Providers.tsx @@ -1,7 +1,6 @@ 'use client' import { trpc } from '@/app/_trpc/client' -import { absoluteUrl } from '@/lib/utils' import { QueryClient, QueryClientProvider } from '@tanstack/react-query' import { httpBatchLink } from '@trpc/client' import { PropsWithChildren, useState } from 'react' @@ -12,7 +11,7 @@ const Providers = ({ children }: PropsWithChildren) => { trpc.createClient({ links: [ httpBatchLink({ - url: absoluteUrl('/api/trpc') + url: `${process.env.NEXT_PUBLIC_BASE_URL}/api/trpc` }) ] }) diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 88b9590..5295242 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -6,12 +6,12 @@ export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)) } -export function absoluteUrl(path: string) { - if (typeof window !== 'undefined') return path - // if (process.env.VERCEL_URL) return `https://${process.env.VERCEL_URL}${path}` - if (process.env.BASE_URL) return `https://${process.env.BASE_URL}${path}` - return `http://localhost:${process.env.PORT ?? 3000}${path}` -} +// export function absoluteUrl(path: string) { +// if (typeof window !== 'undefined') return path +// // if (process.env.VERCEL_URL) return `https://${process.env.VERCEL_URL}${path}` +// if (process.env.BASE_URL) return `https://${process.env.BASE_URL}${path}` +// return `http://localhost:${process.env.PORT ?? 3000}${path}` +// } export function constructMetadata({ title = 'PDF-Ai - the Ai Chat SaaS ', @@ -46,7 +46,7 @@ export function constructMetadata({ creator: '@joshtriedcoding' }, icons, - metadataBase: new URL(`https://${process.env.BASE_URL}`), + metadataBase: new URL(`${process.env.NEXT_PUBLIC_BASE_URL}`), themeColor: '#FFF', ...(noIndex && { robots: { diff --git a/src/trpc/index.ts b/src/trpc/index.ts index 0a6b989..b491cc6 100644 --- a/src/trpc/index.ts +++ b/src/trpc/index.ts @@ -3,7 +3,6 @@ import { TRPCError } from '@trpc/server' import { db } from '@/db' import { z } from 'zod' import { INFINITE_QUERY_LIMIT } from '@/config/infinite-query' -import { absoluteUrl } from '@/lib/utils' import { getUserSubscriptionPlan, stripe } from '@/lib/stripe' import { PLANS } from '@/config/stripe' import bcrypt from 'bcrypt' @@ -22,7 +21,7 @@ export const appRouter = router({ createStripeSession: privateProcedure.mutation(async ({ ctx }) => { const { userId } = ctx - const billingUrl = absoluteUrl('/dashboard/billing') + const billingUrl = `${process.env.NEXT_PUBLIC_BASE_URL}/dashboard/billing` if (!userId) throw new TRPCError({ code: 'UNAUTHORIZED' })