From 801e7c9db17bb6496bf6ec9325eb3bdf6c407b78 Mon Sep 17 00:00:00 2001 From: Felix Wotschofsky Date: Sat, 6 Jan 2024 14:29:47 +0100 Subject: [PATCH] improve error logging --- app/lookup/[domain]/map/page.tsx | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/app/lookup/[domain]/map/page.tsx b/app/lookup/[domain]/map/page.tsx index df9873c..f599ae4 100644 --- a/app/lookup/[domain]/map/page.tsx +++ b/app/lookup/[domain]/map/page.tsx @@ -36,15 +36,18 @@ const MapResultsPage: FC = async ({ }) => { const markers = await Promise.all( Object.entries(regions).map(async ([code, data]) => { - const response = await fetch( - `${ - process.env.SITE_URL || - process.env.VERCEL_URL || - 'http://localhost:3000' - }/lookup/${domain}/map/resolve/${code}?type=A&domain=${domain}` - ); + const url = `${ + process.env.SITE_URL || + (process.env.VERCEL_URL && `https://${process.env.VERCEL_URL}`) || + 'http://localhost:3000' + }/lookup/${domain}/map/resolve/${code}?type=A&domain=${domain}`; + const response = await fetch(url); if (!response.ok) - throw new Error(`Failed to fetch ${code}, ${await response.text()}`); + throw new Error( + `Failed to fetch ${url}, Status: ${ + response.status + },\n\nResponse:\n${await response.text()}` + ); const results = await response.json(); return {