diff --git a/src/pages/admin/edit.astro b/src/pages/admin/edit.astro index ef1dd44..92bab62 100644 --- a/src/pages/admin/edit.astro +++ b/src/pages/admin/edit.astro @@ -55,9 +55,7 @@ import SiteLayout from '../../components/SiteLayout.astro'; // Base API URL - adapt for production vs. development const getApiUrl = (path) => { - return window.location.hostname === 'localhost' - ? `http://localhost:3000/api/${path}` - : `/api/${path}`; + return `/api/${path}`; // Always use relative path for Nginx proxy }; // Load existing content if editing diff --git a/src/pages/admin/index.astro b/src/pages/admin/index.astro index eeec557..eb47a9f 100644 --- a/src/pages/admin/index.astro +++ b/src/pages/admin/index.astro @@ -25,9 +25,7 @@ import SiteLayout from '../../components/SiteLayout.astro'; // This would fetch from your API in production async function fetchBooks() { try { - const apiUrl = window.location.hostname === 'localhost' - ? 'http://localhost:3000/api/content' - : '/api/content'; + const apiUrl = '/api/content'; // Always use relative path for Nginx proxy const response = await fetch(apiUrl, { headers: { @@ -67,9 +65,7 @@ import SiteLayout from '../../components/SiteLayout.astro'; const file = btn.getAttribute('data-file'); try { - const apiUrl = window.location.hostname === 'localhost' - ? `http://localhost:3000/api/content/${file}` - : `/api/content/${file}`; + const apiUrl = `/api/content/${file}`; // Always use relative path for Nginx proxy const response = await fetch(apiUrl, { method: 'DELETE',