Skip API fetch at build time when BACKEND_URL is not set
This commit is contained in:
parent
9a5e6e19d7
commit
368669aa89
4 changed files with 4 additions and 0 deletions
|
|
@ -16,6 +16,7 @@ interface Article {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getArticles(): Promise<Article[]> {
|
async function getArticles(): Promise<Article[]> {
|
||||||
|
if (!process.env.BACKEND_URL) return [];
|
||||||
try {
|
try {
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`${process.env.BACKEND_URL}/api/articles?status=published`,
|
`${process.env.BACKEND_URL}/api/articles?status=published`,
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ interface Event {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getEvents(): Promise<Event[]> {
|
async function getEvents(): Promise<Event[]> {
|
||||||
|
if (!process.env.BACKEND_URL) return [];
|
||||||
try {
|
try {
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`${process.env.BACKEND_URL}/api/events?status=published&limit=100`,
|
`${process.env.BACKEND_URL}/api/events?status=published&limit=100`,
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ interface DocRecord {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getDocuments(): Promise<DocRecord[]> {
|
async function getDocuments(): Promise<DocRecord[]> {
|
||||||
|
if (!process.env.BACKEND_URL) return [];
|
||||||
try {
|
try {
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`${process.env.BACKEND_URL}/api/documents?limit=500`,
|
`${process.env.BACKEND_URL}/api/documents?limit=500`,
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ interface Update {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getUpdates(): Promise<Update[]> {
|
async function getUpdates(): Promise<Update[]> {
|
||||||
|
if (!process.env.BACKEND_URL) return [];
|
||||||
try {
|
try {
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`${process.env.BACKEND_URL}/api/updates?status=published&limit=100`,
|
`${process.env.BACKEND_URL}/api/updates?status=published&limit=100`,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue