updated ui and file creation

This commit is contained in:
2026-03-25 14:09:15 +01:00
parent e53cdfef03
commit fe2489b4ed
5 changed files with 20 additions and 12 deletions

View File

@@ -42,7 +42,7 @@ try {
<body class={`bg-base text-text selection:bg-surface2 selection:text-text ${siteConfig.theme}`}> <body class={`bg-base text-text selection:bg-surface2 selection:text-text ${siteConfig.theme}`}>
<div class="fixed inset-0 z-[-1] bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-surface0 via-base to-base"></div> <div class="fixed inset-0 z-[-1] bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-surface0 via-base to-base"></div>
<nav class="max-w-4xl mx-auto px-6 py-8"> <nav class="max-w-6xl mx-auto px-6 py-8">
<header class="glass px-6 py-4 flex items-center justify-between"> <header class="glass px-6 py-4 flex items-center justify-between">
<div> <div>
<a href="/" class="text-2xl font-bold bg-clip-text text-transparent bg-gradient-to-r from-mauve to-blue block"> <a href="/" class="text-2xl font-bold bg-clip-text text-transparent bg-gradient-to-r from-mauve to-blue block">
@@ -57,11 +57,11 @@ try {
</header> </header>
</nav> </nav>
<main class="max-w-4xl mx-auto px-6 py-8"> <main class="max-w-6xl mx-auto px-6 py-8">
<slot /> <slot />
</main> </main>
<footer class="max-w-4xl mx-auto px-6 py-12 text-center text-sm text-subtext1 border-t border-white/5 mt-12"> <footer class="max-w-6xl mx-auto px-6 py-12 text-center text-sm text-subtext1 border-t border-white/5 mt-12">
<p class="mb-2">{siteConfig.footer}</p> <p class="mb-2">{siteConfig.footer}</p>
<div class="text-subtext0 opacity-50"> <div class="text-subtext0 opacity-50">
&copy; {new Date().getFullYear()} {siteConfig.title} &copy; {new Date().getFullYear()} {siteConfig.title}

View File

@@ -327,7 +327,7 @@ import Layout from '../../layouts/Layout.astro';
delBtn?.addEventListener('click', async () => { delBtn?.addEventListener('click', async () => {
if (confirm(`Delete post "${slugInput.value}" permanently?`)) { if (confirm(`Delete post "${slugInput.value}" permanently?`)) {
try { try {
const res = await fetch(`/api/posts/${slugInput.value}`, { const res = await fetch(`/api/posts/${encodeURIComponent(slugInput.value)}`, {
method: 'DELETE', method: 'DELETE',
headers: { 'Authorization': `Bearer ${token}` } headers: { 'Authorization': `Bearer ${token}` }
}); });

View File

@@ -106,7 +106,7 @@ import Layout from '../../layouts/Layout.astro';
const slug = (e.currentTarget as HTMLElement).dataset.slug; const slug = (e.currentTarget as HTMLElement).dataset.slug;
if (confirm(`Are you sure you want to delete "${slug}"?`)) { if (confirm(`Are you sure you want to delete "${slug}"?`)) {
try { try {
const delRes = await fetch(`/api/posts/${slug}`, { const delRes = await fetch(`/api/posts/${encodeURIComponent(slug)}`, {
method: 'DELETE', method: 'DELETE',
headers: { 'Authorization': `Bearer ${token}` } headers: { 'Authorization': `Bearer ${token}` }
}); });

View File

@@ -8,13 +8,14 @@ export const ALL: APIRoute = async ({ request, params }) => {
return new Response(JSON.stringify({ error: 'Missing path' }), { status: 400 }); return new Response(JSON.stringify({ error: 'Missing path' }), { status: 400 });
} }
// Ensure path is properly encoded
const url = new URL(`${API_URL}/api/${path}`); const url = new URL(`${API_URL}/api/${path}`);
const requestUrl = new URL(request.url); const requestUrl = new URL(request.url);
url.search = requestUrl.search; url.search = requestUrl.search;
// Filter headers to avoid conflicts with the backend container
const headers = new Headers(); const headers = new Headers();
const forbiddenHeaders = ['host', 'connection', 'origin', 'referer', 'content-length']; // Filter headers to avoid conflicts. Content-Type is handled automatically for POST/PUT if we pass arrayBuffer.
const forbiddenHeaders = ['host', 'connection', 'origin', 'referer', 'content-length', 'transfer-encoding'];
request.headers.forEach((value, key) => { request.headers.forEach((value, key) => {
if (!forbiddenHeaders.includes(key.toLowerCase())) { if (!forbiddenHeaders.includes(key.toLowerCase())) {
@@ -23,16 +24,23 @@ export const ALL: APIRoute = async ({ request, params }) => {
}); });
try { try {
console.log(`[Proxy] ${request.method} ${requestUrl.pathname} -> ${url.toString()}`);
let body: any = undefined;
if (request.method !== 'GET' && request.method !== 'HEAD') {
body = await request.arrayBuffer();
}
const response = await fetch(url.toString(), { const response = await fetch(url.toString(), {
method: request.method, method: request.method,
headers: headers, headers: headers,
// Pass the body stream directly for efficiency body: body,
body: request.method !== 'GET' && request.method !== 'HEAD' ? request.body : undefined, // @ts-ignore
// @ts-ignore - duplex is required for streaming bodies in some fetch implementations
duplex: 'half' duplex: 'half'
}); });
// Extract headers for the response console.log(`[Proxy] Backend returned ${response.status} for ${url.toString()}`);
const responseHeaders = new Headers(); const responseHeaders = new Headers();
response.headers.forEach((value, key) => { response.headers.forEach((value, key) => {
responseHeaders.set(key, value); responseHeaders.set(key, value);

View File

@@ -43,7 +43,7 @@ function formatSlug(slug: string) {
</p> </p>
</section> </section>
<div class="grid gap-6"> <div class="grid md:grid-cols-2 lg:grid-cols-3 gap-6">
{error && ( {error && (
<div class="glass p-6 text-red text-center border-red/20"> <div class="glass p-6 text-red text-center border-red/20">
{error} {error}