diff --git a/src/app/find-help/organisation/[slug]/page.tsx b/src/app/find-help/organisation/[slug]/page.tsx index ac070141..26bc2197 100644 --- a/src/app/find-help/organisation/[slug]/page.tsx +++ b/src/app/find-help/organisation/[slug]/page.tsx @@ -13,11 +13,8 @@ interface Props { export default async function OrganisationPage(props: Props) { const { slug } = await props.params; - const baseUrl = process.env.VERCEL_URL - ? `https://${process.env.VERCEL_URL}` - : 'http://localhost:3000'; - - const res = await fetch(`${baseUrl}/api/service-providers/${slug}`, { + // ✅ Use relative path for internal API call + const res = await fetch(`/api/service-providers/${slug}`, { cache: 'no-store', }); @@ -37,7 +34,6 @@ export default async function OrganisationPage(props: Props) { return notFound(); } - // Cast services const rawServices = (data.services || []) as RawService[]; const services = rawServices.map((service, idx) => { @@ -61,8 +57,8 @@ export default async function OrganisationPage(props: Props) { description: service.Info || '', address: service.Address || {}, openTimes, - organisation: data.organisation.name, // ✅ lowercase - organisationSlug: data.organisation.key, // ✅ lowercase + organisation: data.organisation.name, + organisationSlug: data.organisation.key, latitude: coords[1], longitude: coords[0], clientGroups: service.ClientGroups || [], @@ -86,7 +82,6 @@ export default async function OrganisationPage(props: Props) { groupedServices, }; - console.log('✅ DEBUG groupedServices:', JSON.stringify(groupedServices, null, 2)); return ; diff --git a/src/app/find-help/page.tsx b/src/app/find-help/page.tsx index 52ab5354..7c461f9c 100644 --- a/src/app/find-help/page.tsx +++ b/src/app/find-help/page.tsx @@ -6,15 +6,8 @@ import { decodeHtmlEntities } from '@/utils/htmlDecode'; import { categoryKeyToName, subCategoryKeyToName } from '@/utils/categoryLookup'; export default async function FindHelpPage() { - const isServer = typeof window === 'undefined'; - - const baseUrl = isServer - ? process.env.VERCEL_URL - ? `https://${process.env.VERCEL_URL}` - : 'http://localhost:3000' - : ''; - - const res = await fetch(`${baseUrl}/api/services?limit=1000`, { cache: 'no-store' }); + // ✅ Use relative URL for internal API call — safe for local and Vercel + const res = await fetch('/api/services?limit=1000', { cache: 'no-store' }); if (!res.ok) { throw new Error(`Failed to fetch services: ${res.status}`); @@ -66,4 +59,4 @@ export default async function FindHelpPage() { ); -} \ No newline at end of file +}