feat: add admin pages for managing book content with CRUD operations

This commit is contained in:
greg 2025-05-24 09:14:08 +02:00
parent 476bb096b0
commit afeaf931f2
2 changed files with 3 additions and 9 deletions

View File

@ -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

View File

@ -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',