feat: fixing build npm
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
6176567557
commit
5fdc2d4374
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue