diff --git a/src/components/Banner.tsx b/src/components/Banner.tsx index cfe80bc..174b6fd 100644 --- a/src/components/Banner.tsx +++ b/src/components/Banner.tsx @@ -26,7 +26,7 @@ const Banner = () => { const getCoteData = async () => { const res = await axios.get( - `http://nubble-backend-eb-1-env.eba-f5sb82hp.ap-northeast-2.elasticbeanstalk.com/coding-problems?quizDate=${todayDate}`, + `${import.meta.env.VITE_NUBBLE_SERVER}/coding-problems?quizDate=${todayDate}`, ) return res.data.problems } diff --git a/src/hooks/useCheckSession.ts b/src/hooks/useCheckSession.ts index 3cb6e02..8818ac5 100644 --- a/src/hooks/useCheckSession.ts +++ b/src/hooks/useCheckSession.ts @@ -12,14 +12,11 @@ const useCheckSession = () => { return } - await axios.get( - 'http://nubble-backend-eb-1-env.eba-f5sb82hp.ap-northeast-2.elasticbeanstalk.com/auth/sessions/validate', - { - headers: { - 'SESSION-ID': sessionId, - }, + await axios.get(`${import.meta.env.VITE_NUBBLE_SERVER}/auth/sessions/validate`, { + headers: { + 'SESSION-ID': sessionId, }, - ) + }) console.log('로그인 된 상태') } catch (error) { diff --git a/src/hooks/useCoteData.ts b/src/hooks/useCoteData.ts index d151ddd..95412b0 100644 --- a/src/hooks/useCoteData.ts +++ b/src/hooks/useCoteData.ts @@ -39,7 +39,7 @@ const testAuthor = [ }, ] -const headers = { Authorization: `${process.env.GITHUB_TOKEN}` } +const headers = { Authorization: `${import.meta.env.VITE_GITHUB_TOKEN}` } //문제 제목 공백 제거, 소문자로 통일시키는 함수 const normalizeString = (str: string) => { return str @@ -118,9 +118,7 @@ export const useCoteData = () => { const fetchcoteDatas = async () => { try { - const res = await axios.get( - `http://nubble-backend-eb-1-env.eba-f5sb82hp.ap-northeast-2.elasticbeanstalk.com/coding-problems`, - ) + const res = await axios.get(`${import.meta.env.VITE_NUBBLE_SERVER}/coding-problems`) setCoteDatas(res.data.problems) fetchCommits() } catch (error) { diff --git a/src/hooks/useFileUpload.ts b/src/hooks/useFileUpload.ts index 981231f..e0c26b2 100644 --- a/src/hooks/useFileUpload.ts +++ b/src/hooks/useFileUpload.ts @@ -9,17 +9,13 @@ const useFileUpload = () => { try { const formData = new FormData() formData.append('file', file) - - const res = await axios.post( - `http://nubble-backend-eb-1-env.eba-f5sb82hp.ap-northeast-2.elasticbeanstalk.com/files`, - formData, - { - headers: { - 'Content-Type': 'multipart/form-data', - 'SESSION-ID': sessionId, - }, + console.log(`${import.meta.env.VITE_NUBBLE_SERVER}`) + const res = await axios.post(`${import.meta.env.VITE_NUBBLE_SERVER}/files`, formData, { + headers: { + 'Content-Type': 'multipart/form-data', + 'SESSION-ID': sessionId, }, - ) + }) return res.data } catch (error) { setFailed('파일 업로드 실패') diff --git a/src/pages/AddQuestion.tsx b/src/pages/AddQuestion.tsx index fe143cb..4446bb8 100644 --- a/src/pages/AddQuestion.tsx +++ b/src/pages/AddQuestion.tsx @@ -40,9 +40,7 @@ const AddQuestion = () => { useEffect(() => { const getCodingTestList = async () => { try { - const res = await axios.get( - 'http://nubble-backend-eb-1-env.eba-f5sb82hp.ap-northeast-2.elasticbeanstalk.com/coding-problems', - ) + const res = await axios.get(`${import.meta.env.VITE_NUBBLE_SERVER}/coding-problems`) const data = res.data.problems.map((problem: any) => ({ id: problem.problemId, // problemId 필드를 id로 저장 quizDate: problem.quizDate, @@ -95,7 +93,7 @@ const AddQuestion = () => { const postCodingTest = async () => { try { const res = await axios.post( - 'http://nubble-backend-eb-1-env.eba-f5sb82hp.ap-northeast-2.elasticbeanstalk.com/coding-problems', + `${import.meta.env.VITE_NUBBLE_SERVER}/coding-problems`, { quizDate: formData.quizDate, problemTitle: formData.problemTitle, @@ -119,14 +117,11 @@ const AddQuestion = () => { const handleDelete = async (id: number) => { try { // DELETE 요청을 서버로 보냄 - await axios.delete( - `http://nubble-backend-eb-1-env.eba-f5sb82hp.ap-northeast-2.elasticbeanstalk.com/coding-problems/${id}`, - { - headers: { - 'SESSION-ID': sessionId, - }, + await axios.delete(`${import.meta.env.VITE_NUBBLE_SERVER}/coding-problems/${id}`, { + headers: { + 'SESSION-ID': sessionId, }, - ) + }) // 성공적으로 삭제되면 클라이언트에서도 상태를 업데이트 const updatedQuestions = questions.filter((question) => question.id !== id) diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx index 6878184..aa9be30 100644 --- a/src/pages/Home.tsx +++ b/src/pages/Home.tsx @@ -72,15 +72,12 @@ const Home: React.FC = () => { return } - const res = await axios.get( - 'http://nubble-backend-eb-1-env.eba-f5sb82hp.ap-northeast-2.elasticbeanstalk.com/users/me', - { - headers: { - 'Content-Type': 'application/json', - 'SESSION-ID': sessionId, - }, + const res = await axios.get(`${import.meta.env.VITE_NUBBLE_SERVER}/users/me`, { + headers: { + 'Content-Type': 'application/json', + 'SESSION-ID': sessionId, }, - ) + }) console.log(res) localStorage.setItem('userName', res.data.nickname) localStorage.setItem('userId', res.data.username) diff --git a/src/pages/Login.tsx b/src/pages/Login.tsx index e780a8c..03114bb 100644 --- a/src/pages/Login.tsx +++ b/src/pages/Login.tsx @@ -20,7 +20,7 @@ const Login: React.FC = () => { const getUser = async () => { try { const res = await axios.post( - 'http://nubble-backend-eb-1-env.eba-f5sb82hp.ap-northeast-2.elasticbeanstalk.com/auth/sessions', + `${import.meta.env.VITE_NUBBLE_SERVER}/auth/sessions`, { username: id, password: pw, diff --git a/src/pages/PreviewPage.tsx b/src/pages/PreviewPage.tsx index 1a3c74e..0806cb5 100644 --- a/src/pages/PreviewPage.tsx +++ b/src/pages/PreviewPage.tsx @@ -56,7 +56,7 @@ const PreviewPage = () => { const handleSubmit = async () => { try { await axios.post( - 'http://nubble-backend-eb-1-env.eba-f5sb82hp.ap-northeast-2.elasticbeanstalk.com/posts', + `${import.meta.env.VITE_NUBBLE_SERVER}/posts`, { title: markdownTitle, content: markdownContent, diff --git a/src/pages/WritePage.tsx b/src/pages/WritePage.tsx index 77dbe4c..3afab56 100644 --- a/src/pages/WritePage.tsx +++ b/src/pages/WritePage.tsx @@ -119,20 +119,17 @@ const WritePage = () => { } const fetchCategory = async () => { - const res = await axios.get( - `http://nubble-backend-eb-1-env.eba-f5sb82hp.ap-northeast-2.elasticbeanstalk.com/categories`, - { - headers: { - 'Content-Type': 'application/json', - }, + const res = await axios.get(`${import.meta.env.VITE_NUBBLE_SERVER}/categories`, { + headers: { + 'Content-Type': 'application/json', }, - ) + }) setCategories(res.data.categories) } const fetchBoards = async (categoryId: string) => { const res = await axios.get( - `http://nubble-backend-eb-1-env.eba-f5sb82hp.ap-northeast-2.elasticbeanstalk.com/categories/${categoryId}/boards`, + `${import.meta.env.VITE_NUBBLE_SERVER}/categories/${categoryId}/boards`, { headers: { 'Content-Type': 'application/json', @@ -153,7 +150,7 @@ const WritePage = () => { const handleDraft = async () => { try { const res = await axios.post( - 'http://nubble-backend-eb-1-env.eba-f5sb82hp.ap-northeast-2.elasticbeanstalk.com/posts', + `${import.meta.env.VITE_NUBBLE_SERVER}/posts`, { title: markdownTitle, content: markdownContent,