Skip to content

Commit 46e723f

Browse files
committed
Add baseUrl prop to MyApp for dynamic meta tags
1 parent 002b20b commit 46e723f

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

src/pages/_app.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ import { api } from '~/utils/api';
1919

2020
const poppins = Poppins({ weight: ['200', '300', '400', '500', '600', '700'], subsets: ['latin'] });
2121

22-
const MyApp: AppType<{ session: Session | null }> = ({
22+
const MyApp: AppType<{ session: Session | null; baseUrl: string }> = ({
2323
Component,
24-
pageProps: { session, ...pageProps },
24+
pageProps: { session, baseUrl, ...pageProps },
2525
}) => {
2626
return (
2727
<main className={clsx(poppins.className, 'h-full')}>
@@ -53,17 +53,17 @@ const MyApp: AppType<{ session: Session | null }> = ({
5353
<link rel="shortcut icon" href="/favicon.ico" />
5454

5555
<meta name="twitter:card" content="summary" />
56-
<meta name="twitter:url" content={env.NEXTAUTH_URL} />
56+
<meta name="twitter:url" content={baseUrl} />
5757
<meta name="twitter:title" content="SplitPro" />
5858
<meta name="twitter:description" content="Split Expenses with your friends for free" />
59-
<meta name="twitter:image" content={`${env.NEXTAUTH_URL}/og_banner.png`} />
59+
<meta name="twitter:image" content={`${baseUrl}/og_banner.png`} />
6060
<meta name="twitter:creator" content="@KM_Koushik_" />
6161
<meta property="og:type" content="website" />
6262
<meta property="og:title" content="SplitPro" />
6363
<meta property="og:description" content="Split Expenses with your friends for free" />
6464
<meta property="og:site_name" content="SplitPro" />
65-
<meta property="og:url" content={env.NEXTAUTH_URL} />
66-
<meta property="og:image" content={`${env.NEXTAUTH_URL}/og_banner.png`} />
65+
<meta property="og:url" content={baseUrl} />
66+
<meta property="og:image" content={`${baseUrl}/og_banner.png`} />
6767
</Head>
6868
<SessionProvider session={session}>
6969
<ThemeProvider attribute="class" defaultTheme="dark">
@@ -118,4 +118,12 @@ const Auth: React.FC<{ Page: NextPageWithUser; pageProps: any }> = ({ Page, page
118118
return <Page user={data.user} {...pageProps} />;
119119
};
120120

121+
export const getServerSideProps = async () => {
122+
return {
123+
props: {
124+
baseUrl: env.NEXTAUTH_URL,
125+
},
126+
};
127+
};
128+
121129
export default api.withTRPC(MyApp);

0 commit comments

Comments
 (0)