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.
This commit is contained in:
Mauricio Siu
2026-02-27 11:24:56 -06:00
parent a85fb76a95
commit 3479bf74e7
3 changed files with 9 additions and 7 deletions

View File

@@ -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);

View File

@@ -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<Post | null> {
try {
const result = (await api.posts.read({
slug,
include: ["authors"],
include: "authors",
})) as Post;
return result;

View File

@@ -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"