Skip to content

Commit

Permalink
upd files
Browse files Browse the repository at this point in the history
  • Loading branch information
JiangShuuu committed Nov 16, 2023
1 parent f983bcc commit 06a4544
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/components/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface PageProps {
const Dashboard = ({ subscriptionPlan }: PageProps) => {
const [currentlyDeletingFile, setCurrentlyDeletingFile] = useState<string | null>(null)

const utils = trpc.useContext()
const utils = trpc.useUtils()

const { data: files, isLoading } = trpc.getUserFiles.useQuery()

Expand Down
2 changes: 1 addition & 1 deletion src/components/LoginModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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' })}
>
<FaGithub className="h-6 w-6" />
</Button>
Expand Down
3 changes: 1 addition & 2 deletions src/components/Providers.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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`
})
]
})
Expand Down
14 changes: 7 additions & 7 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ',
Expand Down Expand Up @@ -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: {
Expand Down
3 changes: 1 addition & 2 deletions src/trpc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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' })

Expand Down

0 comments on commit 06a4544

Please sign in to comment.