RegWatch frontend : React/Vite -> nginx + Docker/CI homelab
Build & Deploy / build (push) Successful in 18s
Build & Deploy / build (push) Successful in 18s
- URL d'API externalisée (VITE_API_URL bakée au build), plus de localhost en dur - Dockerfile multi-stage pnpm build -> nginx (fallback SPA) - docker-compose (Watchtower) + .gitea/workflows/build.yml Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
// Injecté au build par Vite (VITE_API_URL). Repli sur le backend local en dev.
|
||||
export const API_URL = import.meta.env.VITE_API_URL ?? "http://127.0.0.1:8000";
|
||||
|
||||
export type ApiDocument = {
|
||||
id: number;
|
||||
title: string;
|
||||
ingredient: string;
|
||||
source: string;
|
||||
type: string;
|
||||
date?: string | null;
|
||||
pdf_url: string;
|
||||
};
|
||||
|
||||
export async function getDocuments(): Promise<ApiDocument[]> {
|
||||
const res = await fetch(`${API_URL}/documents`);
|
||||
if (!res.ok) throw new Error(`API error: ${res.status}`);
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export function openPdf(pdfUrl: string): void {
|
||||
window.open(pdfUrl, "_blank", "noopener,noreferrer");
|
||||
}
|
||||
Reference in New Issue
Block a user