feat: add admin pages for managing book content with CRUD operations
This commit is contained in:
parent
476bb096b0
commit
afeaf931f2
@ -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
|
||||
|
||||
@ -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',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user