From 3479bf74e7fecdf0ef8a5d5c5aab19164fd315e0 Mon Sep 17 00:00:00 2001 From: Mauricio Siu Date: Fri, 27 Feb 2026 11:24:56 -0600 Subject: [PATCH] fix: update build command and API URL for local development - Modified the build command in package.json to include webpack. - Updated the local API URL in the blog page component to reflect the new development port. - Refactored the Ghost API request handling to prevent sending the slug as a query parameter, improving error handling. --- apps/website/app/blog/[slug]/page.tsx | 2 +- apps/website/lib/ghost.ts | 12 +++++++----- apps/website/package.json | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/apps/website/app/blog/[slug]/page.tsx b/apps/website/app/blog/[slug]/page.tsx index 5fdc669..3cb9056 100644 --- a/apps/website/app/blog/[slug]/page.tsx +++ b/apps/website/app/blog/[slug]/page.tsx @@ -39,7 +39,7 @@ export async function generateMetadata( "/api/og", process.env.NODE_ENV === "production" ? "https://dokploy.com" - : "http://localhost:3000", + : "http://localhost:3001", ); ogUrl.searchParams.set("slug", slug); diff --git a/apps/website/lib/ghost.ts b/apps/website/lib/ghost.ts index ae2a933..339f584 100644 --- a/apps/website/lib/ghost.ts +++ b/apps/website/lib/ghost.ts @@ -15,10 +15,11 @@ const api = GhostContentAPI({ // @ts-ignore makeRequest: ({ url, method, params, headers }) => { const apiUrl = new URL(url); - // @ts-ignore - Object.keys(params).map((key) => - apiUrl.searchParams.set(key, encodeURIComponent(params[key])), - ); + // Slug is already in the path; Ghost returns 422 if we also send it as query param + const { slug: _slug, ...queryParams } = params; + for (const key of Object.keys(queryParams)) { + apiUrl.searchParams.set(key, encodeURIComponent(queryParams[key])); + } return fetch(apiUrl.toString(), { method, headers }) .then(async (res) => { @@ -31,6 +32,7 @@ const api = GhostContentAPI({ }) .catch((error) => { console.error("Fetch error:", error); + throw error; }); }, }); @@ -95,7 +97,7 @@ export async function getPost(slug: string): Promise { try { const result = (await api.posts.read({ slug, - include: ["authors"], + include: "authors", })) as Post; return result; diff --git a/apps/website/package.json b/apps/website/package.json index c7f7e80..f0c4ae5 100644 --- a/apps/website/package.json +++ b/apps/website/package.json @@ -5,7 +5,7 @@ "private": true, "scripts": { "dev": "next dev --port 3001", - "build": "next build", + "build": "next build --webpack", "start": "next start", "lint": "next lint", "typecheck": "tsc --noEmit"