From 871a1b4c512a7d27a5e8f67a8e18414018afbfa1 Mon Sep 17 00:00:00 2001 From: IMHOJEONG <39ghwjd@naver.com> Date: Sat, 30 Dec 2023 01:23:31 +0900 Subject: [PATCH] [revise]: revise page.tsx for fetch error --- .../app/computer_science/algorithms/page.tsx | 45 ++++++++++--------- .../app/computer_science/page.tsx | 44 ++++++++++-------- 2 files changed, 51 insertions(+), 38 deletions(-) diff --git a/apps/pwrcode-frontend/app/computer_science/algorithms/page.tsx b/apps/pwrcode-frontend/app/computer_science/algorithms/page.tsx index c89957c..5764779 100755 --- a/apps/pwrcode-frontend/app/computer_science/algorithms/page.tsx +++ b/apps/pwrcode-frontend/app/computer_science/algorithms/page.tsx @@ -7,26 +7,31 @@ import { Code } from 'bright'; // app/page.js export default async function RemoteMdxPage() { // MDX text - can be from a local file, database, CMS, fetch, anywhere... - const res = await fetch( - 'http://localhost:9000/computer-science/algorithms_and_data_structures/index.mdx', - { - headers: { - 'Content-Type': 'text/html', + try { + const res = await fetch( + `http://${process.env.NEXT_PUBLIC_FILE_API}/computer-science/algorithms_and_data_structures/index.mdx`, + { + headers: { + 'Content-Type': 'text/html', + }, }, - }, - ); - const jsonData = await res.text(); + ); - return ( - Loading...}> - - - ); + const jsonData = await res.text(); + + return ( + Loading...}> + + + ); + } catch (error) { + console.log(error); + } } diff --git a/apps/pwrcode-frontend/app/computer_science/page.tsx b/apps/pwrcode-frontend/app/computer_science/page.tsx index 02e0cd2..91fe1f4 100755 --- a/apps/pwrcode-frontend/app/computer_science/page.tsx +++ b/apps/pwrcode-frontend/app/computer_science/page.tsx @@ -7,23 +7,31 @@ import { Code } from 'bright'; // app/page.js export default async function RemoteMdxPage() { // MDX text - can be from a local file, database, CMS, fetch, anywhere... - const res = await fetch('http://localhost:9000/computer-science/index.mdx', { - headers: { - 'Content-Type': 'text/html', - }, - }); - const jsonData = await res.text(); + try { + const res = await fetch( + `http://${process.env.NEXT_PUBLIC_FILE_API}/computer-science/index.mdx`, + { + headers: { + 'Content-Type': 'text/html', + }, + }, + ); - return ( - Loading...}> - - - ); + const jsonData = await res.text(); + + return ( + Loading...}> + + + ); + } catch (error) { + console.log(error); + } }