From 5fc5320500c9ec9799fb24909a73aff04bf2755d Mon Sep 17 00:00:00 2001 From: GitHub Copilot Date: Thu, 24 Apr 2025 17:51:08 -0400 Subject: [PATCH] fix: Update API fetch calls to use relative paths for consistency --- src/pages/index.astro | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/pages/index.astro b/src/pages/index.astro index d4ae559..a7ad627 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -9,11 +9,8 @@ export interface Props { transactions: Transaction[]; } -// Get the base URL from the incoming request -const baseUrl = new URL(Astro.request.url).origin; - -// Fetch accounts from API using absolute URL -const accountsResponse = await fetch(`${baseUrl}/api/accounts`); +// Fetch accounts from API using relative path +const accountsResponse = await fetch(`/api/accounts`); const accounts: Account[] = await accountsResponse.json(); // Initialize with first account or empty account if none exist @@ -24,10 +21,10 @@ const initialAccount: Account = accounts[0] || { balance: 0 }; -// Fetch initial transactions if we have an account, using absolute URL +// Fetch initial transactions if we have an account, using relative path let initialTransactions: Transaction[] = []; if (initialAccount.id) { - const transactionsResponse = await fetch(`${baseUrl}/api/accounts/${initialAccount.id}/transactions`); + const transactionsResponse = await fetch(`/api/accounts/${initialAccount.id}/transactions`); initialTransactions = await transactionsResponse.json(); } ---