diff --git a/api/game/apis.ts b/api/game/apis.ts index 7b63651..37a5964 100644 --- a/api/game/apis.ts +++ b/api/game/apis.ts @@ -1,9 +1,7 @@ -const BASE_URL = process.env.NEXT_PUBLIC_API_KEY; - export async function getMonthSchedules(params: string) { try { const res = await fetch( - `${BASE_URL}/game/monthschedule?yearMonth=${params}` + `/api/game/monthschedule?yearMonth=${params}` ); if (!res.ok) { @@ -21,7 +19,7 @@ export async function getMonthSchedules(params: string) { export async function getAllSchedules(params: string) { try { const res = await fetch( - `${BASE_URL}/game/allgameschedule?yearMonth=${params}` + `/api/game/allgameschedule?yearMonth=${params}` ); if (!res.ok) { @@ -41,7 +39,7 @@ export const fetchBoxscore = async (gameDate?: number, gmkey?: string) => { const queryparams = gameDate && gmkey ? `?gameDate=${gameDate}&gmkey=${gmkey}` : ""; - const URL = `${BASE_URL}/game/boxscore${queryparams}`; + const URL = `/api/game/boxscore${queryparams}`; const response = await fetch(URL); diff --git a/api/player/apis.ts b/api/player/apis.ts index aa755d0..fb1134b 100644 --- a/api/player/apis.ts +++ b/api/player/apis.ts @@ -5,11 +5,9 @@ import { PitcherResponse, } from "./types"; -const BASE_URL = process.env.NEXT_PUBLIC_API_KEY; - // player - 코치 리스트 export const getCoachList = async (): Promise => { - const url = `${BASE_URL}/player/coachlist`; + const url = `/api/player/coachlist`; const res = await fetch(url); if (!res.ok) { @@ -22,7 +20,7 @@ export const getCoachList = async (): Promise => { // player - 투수 리스트 export const getPitcherList = async (): Promise => { - const url = `${BASE_URL}/player/pitcherlist`; + const url = `/api/player/pitcherlist`; const res = await fetch(url, { method: "GET" }); if (!res.ok) { throw new Error("Failed to fetch coach list"); @@ -37,7 +35,7 @@ export const getCoachDetail = async ( pcode: string ): Promise => { const queryparam = pcode ? `coachdetail?pcode=${pcode}` : ""; - const url = `${BASE_URL}/player/${queryparam}`; + const url = `/api/player/${queryparam}`; const response = await fetch(url, { method: "GET" }); if (!response.ok) { diff --git a/next.config.mjs b/next.config.mjs index c5f9b58..f461b7a 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -1,5 +1,15 @@ /** @type {import('next').NextConfig} */ const nextConfig = { + reactStrictMode: true, + async rewrites() { + return [ + { + source: "/api/:path*", // 모든 /api/* 요청을 프록시 (현재 API 서버의 모든 엔드포인트는는 /api/*로 시작) + destination: `http://${process.env.NEXT_PUBLIC_API_KEY}/api/:path*`, // 실제 API 서버(백엔드)로 Request + }, + ]; + }, + env: { BASE_URL: process.env.BASE_URL, },