Files
portfolio/app/api/fetchProject/route.tsx
denshooter a7d636bff4 Dev (#47)
* 🚀 refactor: simplify deployment process in workflow file

* 🚀 chore: add IMAGE_NAME to GITHUB_ENV for deployment workflow

*  chore: simplify deployment logging in workflow file

* 🚀 fix: correct container name in deployment script logic

* 🚀 refactor: rename job and streamline deployment steps

* Update README.md

*  fix: prevent multiple form submissions in Contact component

*  feat: honeypot and timestamp checks to form submission

*  refactor: simplify contact form and improve UI elements

*  feat: add responsive masonry layout for projects display

*  style: Update project title size and improve layout visibility

*  fix: remove unnecessary test assertions and improve act usage

*  chore: add @types/react-responsive-masonry package

fixing with this import error on building

*  chore: remove unused dev dependencies from package-lock.json

*  refactor: update environment variable usage and add caching

*  refactor: update environment variables and dependencies

*  chore: streamline Dockerfile and remove redundant steps
2025-02-23 17:39:04 +01:00

33 lines
938 B
TypeScript

import { NextResponse } from "next/server";
export const runtime = "nodejs"; // Force Node runtime
const GHOST_API_URL = process.env.GHOST_API_URL;
const GHOST_API_KEY = process.env.GHOST_API_KEY;
export async function GET(request: Request) {
const { searchParams } = new URL(request.url);
const slug = searchParams.get("slug");
if (!slug) {
return NextResponse.json({ error: "Slug is required" }, { status: 400 });
}
try {
const response = await fetch(
`${GHOST_API_URL}/ghost/api/content/posts/slug/${slug}/?key=${GHOST_API_KEY}`,
);
if (!response.ok) {
throw new Error(`Failed to fetch post: ${response.statusText}`);
}
const post = await response.json();
return NextResponse.json(post);
} catch (error) {
console.error("Failed to fetch post from Ghost:", error);
return NextResponse.json(
{ error: "Failed to fetch project" },
{ status: 500 },
);
}
}