Skip to content

Commit

Permalink
fix: get OG origin for dynamic metadata
Browse files Browse the repository at this point in the history
Signed-off-by: Urban Vidovič <[email protected]>
  • Loading branch information
pseudobun committed Feb 5, 2024
1 parent 66428e1 commit 48f1bdd
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { ResolvingMetadata } from 'next';
import { headers } from 'next/headers';
import { notFound } from 'next/navigation';
import { createClient } from '@supabase/supabase-js';
import { VerifiablePresentation } from '@veramo/core';
Expand Down Expand Up @@ -98,13 +100,18 @@ export async function generateMetadata({
};
}) {
const { presentation, title } = await getPresentation(id);

const headersList = headers();
const referrer = headersList.get('referer');
let url = null;
if (!presentation) return {};
if (referrer) {
const parsedUrl = new URL(referrer);
url = `${parsedUrl.protocol}//${parsedUrl.host}`;
}
const finallyUrl =
process.env.NEXT_PUBLIC_APP_URL || url || 'https://masca.io';

// const url = process.env.NEXT_PUBLIC_APP_URL ?? 'https://masca.io';
const url = 'http://localhost:3000';

const ogUrl = new URL(`${url}/api/og`);
const ogUrl = new URL(`${finallyUrl}/api/og`);
ogUrl.searchParams.set('type', 'share-presentation');
ogUrl.searchParams.set('holder', presentation.holder);
ogUrl.searchParams.set(
Expand Down

0 comments on commit 48f1bdd

Please sign in to comment.