Skip API fetch at build time when BACKEND_URL is not set

This commit is contained in:
Chris Haulmark 2026-05-25 08:37:08 -06:00
parent 9a5e6e19d7
commit 368669aa89
4 changed files with 4 additions and 0 deletions

View file

@ -16,6 +16,7 @@ interface Article {
}
async function getArticles(): Promise<Article[]> {
if (!process.env.BACKEND_URL) return [];
try {
const res = await fetch(
`${process.env.BACKEND_URL}/api/articles?status=published`,

View file

@ -18,6 +18,7 @@ interface Event {
}
async function getEvents(): Promise<Event[]> {
if (!process.env.BACKEND_URL) return [];
try {
const res = await fetch(
`${process.env.BACKEND_URL}/api/events?status=published&limit=100`,

View file

@ -17,6 +17,7 @@ interface DocRecord {
}
async function getDocuments(): Promise<DocRecord[]> {
if (!process.env.BACKEND_URL) return [];
try {
const res = await fetch(
`${process.env.BACKEND_URL}/api/documents?limit=500`,

View file

@ -15,6 +15,7 @@ interface Update {
}
async function getUpdates(): Promise<Update[]> {
if (!process.env.BACKEND_URL) return [];
try {
const res = await fetch(
`${process.env.BACKEND_URL}/api/updates?status=published&limit=100`,