From 34871d2e641d086a776b757354341cb33f4f07a0 Mon Sep 17 00:00:00 2001 From: JeonYooDeok Date: Fri, 7 Jun 2024 16:42:39 +0900 Subject: [PATCH] =?UTF-8?q?feat=20:=20=EC=BB=A4=EB=AE=A4=EB=8B=88=ED=8B=B0?= =?UTF-8?q?=20api=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/community/[category]/[id]/route.ts | 30 -------------- app/api/community/[category]/route.ts | 46 ---------------------- 2 files changed, 76 deletions(-) delete mode 100644 app/api/community/[category]/[id]/route.ts delete mode 100644 app/api/community/[category]/route.ts diff --git a/app/api/community/[category]/[id]/route.ts b/app/api/community/[category]/[id]/route.ts deleted file mode 100644 index 29a0a68..0000000 --- a/app/api/community/[category]/[id]/route.ts +++ /dev/null @@ -1,30 +0,0 @@ -import type { NextRequest } from "next/server" - -export const GET = async ( - request: NextRequest, - context: { params: { category: string; id: number } } -) => { - const { category, id } = context.params - - try { - const response = await fetch( - // `http://localhost:3001/${category}/${id}`, - `https://711.ha-ving.store/boards/${category}/${id}`, - { - headers: { - Authorization: - "Bearer eyJhbGciOiJIUzUxMiJ9.eyJpbWFnZSI6Imh0dHBzOi8vYXZhdGFycy5naXRodWJ1c2VyY29udGVudC5jb20vdS83OTI3MDIyOD92PTQiLCJwYXNzd29yZCI6IiQyYSQxMCRleHhmWXAveXZzNHpiY3cyRFNDalZlREFDaTVlcWZma01HaDlsVWwwTXFBRWRUM2h5WDVEeSIsInBob25lIjoiMDEwMTExMTIyMjIiLCJyb2xlcyI6WyJST0xFX1VTRVIiXSwibmlja25hbWUiOiJuaWNrbmFtZTEiLCJpZCI6MjEsInVzZXJuYW1lIjoidXNlciIsImF1dGgiOlt7ImF1dGhvcml0eSI6IlJPTEVfVVNFUiJ9XSwiaWF0IjoxNzE3MDU5MjA5LCJleHAiOjE3MTk2NTEyMDl9.4bpxNGqYITfq2174mngAguJK3gQZ5gl7KzWB8N5eMQ4TV-e8_Ka7xlzCdGH8u6XEoiMywHZwJLM1_7tlAqtt0A" - }, - cache: "no-store" - } - ) - if (response.ok) { - const responseData = await response.json() - return Response.json(responseData.data) - } else { - console.error("게시물 불러오기를 실패했습니다.") - } - } catch (error) { - console.error("에러 발생:", error) - } -} diff --git a/app/api/community/[category]/route.ts b/app/api/community/[category]/route.ts deleted file mode 100644 index 7a743e2..0000000 --- a/app/api/community/[category]/route.ts +++ /dev/null @@ -1,46 +0,0 @@ -import type { NextRequest } from "next/server" - -export const GET = async ( - request: NextRequest, - context: { params: { category: string } } -) => { - const { category } = context.params - const { searchParams } = request.nextUrl - // let url = `http://localhost:3001/${category}` - - const keyword = searchParams.get("keyword") - const page = searchParams.get("page") - const catid = - searchParams.get("catid") === "undefined" || - searchParams.get("catid") === null - ? "0" - : searchParams.get("catid") - console.log(keyword) - console.log(catid) - - let url = `https://711.ha-ving.store/boards/${category}?category-id=${catid}&page=${page}` - // searchParams가 비어있지 않고, title이 존재하면서 값이 "undefined"가 아닌 경우에만 title을 URL에 추가합니다. - if (searchParams && keyword !== undefined && keyword !== "undefined") { - // url += `?keyword=${searchParams.get("keyword")}` - url = `https://711.ha-ving.store/boards/${category}?category-id=${catid}&keyword=${keyword}&page=${page}` - } - - try { - const response = await fetch(url, { - headers: { - Authorization: - "Bearer eyJhbGciOiJIUzUxMiJ9.eyJpbWFnZSI6Imh0dHBzOi8vYXZhdGFycy5naXRodWJ1c2VyY29udGVudC5jb20vdS83OTI3MDIyOD92PTQiLCJwYXNzd29yZCI6IiQyYSQxMCRleHhmWXAveXZzNHpiY3cyRFNDalZlREFDaTVlcWZma01HaDlsVWwwTXFBRWRUM2h5WDVEeSIsInBob25lIjoiMDEwMTExMTIyMjIiLCJyb2xlcyI6WyJST0xFX1VTRVIiXSwibmlja25hbWUiOiJuaWNrbmFtZTEiLCJpZCI6MjEsInVzZXJuYW1lIjoidXNlciIsImF1dGgiOlt7ImF1dGhvcml0eSI6IlJPTEVfVVNFUiJ9XSwiaWF0IjoxNzE3MDU5MjA5LCJleHAiOjE3MTk2NTEyMDl9.4bpxNGqYITfq2174mngAguJK3gQZ5gl7KzWB8N5eMQ4TV-e8_Ka7xlzCdGH8u6XEoiMywHZwJLM1_7tlAqtt0A" - }, - cache: "no-store" - }) - if (response.ok) { - console.log(url) - const responseData = await response.json() - return Response.json(responseData.data) - } else { - console.error("게시물 불러오기를 실패했습니다.") - } - } catch (error) { - console.error("에러 발생:", error) - } -}