feat: fixing build npm
continuous-integration/drone/push Build is passing Details

This commit is contained in:
hanif salafi 2026-04-10 18:59:01 +07:00
parent 6176567557
commit 5fdc2d4374
2 changed files with 16 additions and 11 deletions

View File

@ -2,7 +2,7 @@
FROM node:20-alpine FROM node:20-alpine
# Mengatur port # Mengatur port
ENV PORT 3000 ENV PORT=3000
# Install pnpm secara global # Install pnpm secara global
RUN npm install -g pnpm RUN npm install -g pnpm

View File

@ -14,6 +14,7 @@ export async function publicFetch<T>(path: string): Promise<T | null> {
const base = apiBase(); const base = apiBase();
if (!base) return null; if (!base) return null;
const url = `${base}${path.startsWith("/") ? path : `/${path}`}`; const url = `${base}${path.startsWith("/") ? path : `/${path}`}`;
try {
const res = await fetch(url, { const res = await fetch(url, {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@ -24,4 +25,8 @@ export async function publicFetch<T>(path: string): Promise<T | null> {
if (!res.ok) return null; if (!res.ok) return null;
const json = (await res.json()) as { data?: T }; const json = (await res.json()) as { data?: T };
return json.data ?? null; return json.data ?? null;
} catch {
// e.g. ECONNREFUSED during `next build` in Docker when API is not running
return null;
}
} }