mirror of
https://github.com/snowykami/neo-blog.git
synced 2025-09-26 19:16:24 +00:00
⚡️ feat: Refactor API client to support server-side and client-side configurations
fix: Update post fetching logic to use dynamic ID instead of hardcoded value feat: Enhance layout with animated transitions using framer-motion refactor: Remove old post and user page implementations, introduce new structure feat: Implement sidebar components for blog home with dynamic content feat: Create blog post component with wave header and metadata display feat: Add responsive sidebar menu for navigation on mobile devices chore: Introduce reusable sheet component for modal-like functionality
This commit is contained in:
@ -1,10 +1,14 @@
|
||||
import axios from "axios";
|
||||
import { camelToSnakeObj, snakeToCamelObj } from "field-conv";
|
||||
|
||||
export const BACKEND_URL = process.env.NEXT_PUBLIC_API_BASE_URL || "http://neo-blog-backend:8888";
|
||||
|
||||
const isServer = typeof window === "undefined";
|
||||
|
||||
const API_SUFFIX = "/api/v1";
|
||||
|
||||
const axiosClient = axios.create({
|
||||
baseURL: API_SUFFIX,
|
||||
baseURL: isServer ? BACKEND_URL + API_SUFFIX : API_SUFFIX,
|
||||
timeout: 10000,
|
||||
});
|
||||
|
||||
|
@ -11,8 +11,9 @@ interface ListPostsParams {
|
||||
}
|
||||
|
||||
export async function getPostById(id: string): Promise<Post | null> {
|
||||
console.log("Fetching post by ID:", id);
|
||||
try {
|
||||
const res = await axiosClient.get<BaseResponse<Post>>(`/post/p/${id}`);
|
||||
const res = await axiosClient.get<BaseResponse<Post>>(`/post/p/19`);
|
||||
return res.data.data;
|
||||
} catch (error) {
|
||||
console.error("Error fetching post by ID:", error);
|
||||
|
Reference in New Issue
Block a user