feat : BBS 게시판을 백엔드 스크랩 게시물 API로 교체 (JWT 인증, 읽음 처리)
SpecialSource Frontend (React) CD / deploy (push) Successful in 13s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
headporterandClaude Opus 5.5 committed 2026-11-23 17:35:51 +09:00
1 parent cc814a484b
commit 4b10d4d3b2
11 files changed
+197 -85

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
import type { Feed, ListKind } from "./types";
// 개발은 로컬 백엔드 직접 호출, 운영(nginx)은 같은 도메인의 /api 프록시. NEXT_PUBLIC_API_URL로 덮어쓰기 가능
export const API_URL =
process.env.NEXT_PUBLIC_API_URL ?? (process.env.NODE_ENV === "development" ? "http://localhost:8080" : "");
/** 토큰 만료/누락 (백엔드가 401 또는 403으로 응답) */
export class AuthError extends Error {}
async function call(path: string, token: string, init?: RequestInit) {
const res = await fetch(`${API_URL}${path}`, { ...init, headers: { Authorization: `Bearer ${token}` } });
if (res.status === 401 || res.status === 403) throw new AuthError("※ 로그인이 만료되었습니다. 다시 로그인하세요.");
if (!res.ok) throw new Error(`※ 서버 오류 (${res.status})`);
return res;
}
// ponytail: 첫 페이지 30건만 가져옴. 페이지 넘김이 필요해지면 page 파라미터 추가
export async function fetchFeed(token: string, kind: ListKind): Promise<Feed> {
const res = await call(`/api/scraped-posts${kind === "viewed" ? "/viewed" : ""}?size=30`, token);
const data = await res.json(); // Spring Page 응답: { content: [...], totalElements, ... }
return { kind, posts: data.content, total: data.totalElements };
}
export const markViewed = (token: string, id: number) =>
call(`/api/scraped-posts/${id}/view`, token, { method: "POST" });