.
All checks were successful
Deploy blog-frontend / build-and-deploy (push) Successful in 2m9s

This commit is contained in:
박원엽
2026-05-29 14:51:46 +09:00
parent b371200515
commit f26713e0ea
2 changed files with 13 additions and 2 deletions

View File

@@ -28,6 +28,14 @@ const buildPostListUrl = (params: PublicPostListParams = {}) => {
return `${API_URL}/api/posts?${searchParams.toString()}`;
};
const encodeSlugPathSegment = (slug: string) => {
try {
return encodeURIComponent(decodeURIComponent(slug));
} catch {
return encodeURIComponent(slug);
}
};
export const fetchPublicPosts = async (
params: PublicPostListParams = {},
): Promise<PostListResponse | null> => {
@@ -50,7 +58,7 @@ export const fetchPublicPosts = async (
export const fetchPublicPost = async (slug: string): Promise<Post | null> => {
try {
const response = await fetch(`${API_URL}/api/posts/${encodeURIComponent(slug)}`, {
const response = await fetch(`${API_URL}/api/posts/${encodeSlugPathSegment(slug)}`, {
method: 'GET',
headers: { 'Content-Type': 'application/json' },
next: { revalidate: 60 },
@@ -65,4 +73,3 @@ export const fetchPublicPost = async (slug: string): Promise<Post | null> => {
return null;
}
};