From 58b3d82b855d0fa4187adcb70e4588631f43fc74 Mon Sep 17 00:00:00 2001 From: jtricerolph Date: Wed, 1 Jul 2026 17:55:36 +0000 Subject: [PATCH] Fix API paths and make hotel name configurable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - /api/notices → /notices/api/notices to match nginx location block (was returning portal index.html causing JSON parse error) - Add VITE_HOTEL_NAME build arg, remove hardcoded hotel name - Add vite-env.d.ts for TypeScript import.meta.env support Co-Authored-By: Claude Sonnet 4.6 --- frontend/Dockerfile | 2 ++ frontend/src/components/AuthGate.tsx | 2 +- frontend/src/components/NoticeBoard.tsx | 8 ++++---- frontend/src/vite-env.d.ts | 9 +++++++++ 4 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 frontend/src/vite-env.d.ts diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 9a9862a..4bed2a7 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -3,6 +3,8 @@ WORKDIR /app COPY package.json . RUN npm install COPY . . +ARG VITE_HOTEL_NAME="Number Four at Stow" +ENV VITE_HOTEL_NAME=$VITE_HOTEL_NAME RUN npm run build FROM nginx:alpine diff --git a/frontend/src/components/AuthGate.tsx b/frontend/src/components/AuthGate.tsx index d5eea72..0137f25 100644 --- a/frontend/src/components/AuthGate.tsx +++ b/frontend/src/components/AuthGate.tsx @@ -85,7 +85,7 @@ export function AuthGate({ children }: Props) { Noticeboard

- Hotel Number Four + {import.meta.env.VITE_HOTEL_NAME}

{ const params = category !== 'all' ? `?category=${category}` : '' - fetch(`/api/notices${params}`, { credentials: 'include' }) + fetch(`/notices/api/notices${params}`, { credentials: 'include' }) .then(r => r.json()) .then(setNotices) }, [category, forceRefresh]) async function togglePin(id: number) { - await fetch(`/api/notices/${id}/pin`, { method: 'PATCH', credentials: 'include' }) + await fetch(`/notices/api/notices/${id}/pin`, { method: 'PATCH', credentials: 'include' }) forceRefresh() } async function deleteNotice(id: number) { if (!confirm('Delete this notice?')) return - await fetch(`/api/notices/${id}`, { method: 'DELETE', credentials: 'include' }) + await fetch(`/notices/api/notices/${id}`, { method: 'DELETE', credentials: 'include' }) forceRefresh() } @@ -155,7 +155,7 @@ function PostForm({ onPosted }: { onPosted: () => void }) { setSubmitting(true) setError('') try { - const res = await fetch('/api/notices', { + const res = await fetch('/notices/api/notices', { method: 'POST', credentials: 'include', headers: { 'Content-Type': 'application/json' }, diff --git a/frontend/src/vite-env.d.ts b/frontend/src/vite-env.d.ts new file mode 100644 index 0000000..5ed2038 --- /dev/null +++ b/frontend/src/vite-env.d.ts @@ -0,0 +1,9 @@ +/// + +interface ImportMetaEnv { + readonly VITE_HOTEL_NAME: string +} + +interface ImportMeta { + readonly env: ImportMetaEnv +}