Skip to content

Commit e366b3b

Browse files
james-crossJames-Cross
andauthored
both FindHelpPage and OrganisationPage to use a robust NEXT_PUBLIC_BASE_URL environment variable for server-side API fetches (#119)
Co-authored-by: James-Cross <james@streetsupport.net>
1 parent 5fa18de commit e366b3b

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/app/find-help/organisation/[slug]/page.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ interface Props {
1313
export default async function OrganisationPage(props: Props) {
1414
const { slug } = await props.params;
1515

16-
// ✅ Use relative path for internal API call
17-
const res = await fetch(`/api/service-providers/${slug}`, {
16+
// ✅ Use absolute URL for server fetch
17+
const baseUrl = process.env.NEXT_PUBLIC_BASE_URL || 'http://localhost:3000';
18+
19+
const res = await fetch(`${baseUrl}/api/service-providers/${slug}`, {
1820
cache: 'no-store',
1921
});
2022

src/app/find-help/page.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ import { decodeHtmlEntities } from '@/utils/htmlDecode';
66
import { categoryKeyToName, subCategoryKeyToName } from '@/utils/categoryLookup';
77

88
export default async function FindHelpPage() {
9-
// ✅ Use relative URL for internal API call — safe for local and Vercel
10-
const res = await fetch('/api/services?limit=1000', { cache: 'no-store' });
9+
// ✅ Use absolute URL for server fetch, relative for client
10+
const baseUrl = process.env.NEXT_PUBLIC_BASE_URL || 'http://localhost:3000';
11+
12+
const res = await fetch(`${baseUrl}/api/services?limit=1000`, { cache: 'no-store' });
1113

1214
if (!res.ok) {
1315
throw new Error(`Failed to fetch services: ${res.status}`);

0 commit comments

Comments
 (0)