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 +}