mirror of
https://github.com/acedanger/finance.git
synced 2025-12-05 22:50:12 -08:00
fix: Update API fetch calls to use relative paths for consistency
This commit is contained in:
@@ -9,11 +9,8 @@ export interface Props {
|
|||||||
transactions: Transaction[];
|
transactions: Transaction[];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the base URL from the incoming request
|
// Fetch accounts from API using relative path
|
||||||
const baseUrl = new URL(Astro.request.url).origin;
|
const accountsResponse = await fetch(`/api/accounts`);
|
||||||
|
|
||||||
// Fetch accounts from API using absolute URL
|
|
||||||
const accountsResponse = await fetch(`${baseUrl}/api/accounts`);
|
|
||||||
const accounts: Account[] = await accountsResponse.json();
|
const accounts: Account[] = await accountsResponse.json();
|
||||||
|
|
||||||
// Initialize with first account or empty account if none exist
|
// Initialize with first account or empty account if none exist
|
||||||
@@ -24,10 +21,10 @@ const initialAccount: Account = accounts[0] || {
|
|||||||
balance: 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[] = [];
|
let initialTransactions: Transaction[] = [];
|
||||||
if (initialAccount.id) {
|
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();
|
initialTransactions = await transactionsResponse.json();
|
||||||
}
|
}
|
||||||
---
|
---
|
||||||
|
|||||||
Reference in New Issue
Block a user