Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions src/app/find-help/organisation/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
});

Expand All @@ -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) => {
Expand All @@ -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 || [],
Expand All @@ -86,7 +82,6 @@ export default async function OrganisationPage(props: Props) {
groupedServices,
};


console.log('✅ DEBUG groupedServices:', JSON.stringify(groupedServices, null, 2));

return <OrganisationShell organisation={organisation} />;
Expand Down
13 changes: 3 additions & 10 deletions src/app/find-help/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand Down Expand Up @@ -66,4 +59,4 @@ export default async function FindHelpPage() {
</div>
</LocationProvider>
);
}
}
Loading