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
|
// Base API URL - adapt for production vs. development
|
||||||
const getApiUrl = (path) => {
|
const getApiUrl = (path) => {
|
||||||
return window.location.hostname === 'localhost'
|
return `/api/${path}`; // Always use relative path for Nginx proxy
|
||||||
? `http://localhost:3000/api/${path}`
|
|
||||||
: `/api/${path}`;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Load existing content if editing
|
// Load existing content if editing
|
||||||
|
|||||||
@ -25,9 +25,7 @@ import SiteLayout from '../../components/SiteLayout.astro';
|
|||||||
// This would fetch from your API in production
|
// This would fetch from your API in production
|
||||||
async function fetchBooks() {
|
async function fetchBooks() {
|
||||||
try {
|
try {
|
||||||
const apiUrl = window.location.hostname === 'localhost'
|
const apiUrl = '/api/content'; // Always use relative path for Nginx proxy
|
||||||
? 'http://localhost:3000/api/content'
|
|
||||||
: '/api/content';
|
|
||||||
|
|
||||||
const response = await fetch(apiUrl, {
|
const response = await fetch(apiUrl, {
|
||||||
headers: {
|
headers: {
|
||||||
@ -67,9 +65,7 @@ import SiteLayout from '../../components/SiteLayout.astro';
|
|||||||
const file = btn.getAttribute('data-file');
|
const file = btn.getAttribute('data-file');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const apiUrl = window.location.hostname === 'localhost'
|
const apiUrl = `/api/content/${file}`; // Always use relative path for Nginx proxy
|
||||||
? `http://localhost:3000/api/content/${file}`
|
|
||||||
: `/api/content/${file}`;
|
|
||||||
|
|
||||||
const response = await fetch(apiUrl, {
|
const response = await fetch(apiUrl, {
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user