From 4bc181a924090bbf4036aae871b355dbdfa1ee2c Mon Sep 17 00:00:00 2001 From: Rikuoh Tsujitani <mail@riq0h.jp> Date: Sat, 15 Feb 2025 22:34:19 +0900 Subject: [PATCH] =?UTF-8?q?=E7=92=B0=E5=A2=83=E5=A4=89=E6=95=B0=E3=81=AE?= =?UTF-8?q?=E8=A8=AD=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/.env | 1 + frontend/src/components/ApiTest.vue | 2 +- frontend/src/components/ChatRoom.vue | 4 ++-- frontend/src/components/ChatRooms.vue | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) create mode 100644 frontend/.env diff --git a/frontend/.env b/frontend/.env new file mode 100644 index 0000000..5317fce --- /dev/null +++ b/frontend/.env @@ -0,0 +1 @@ +VITE_API_URL=http://localhost:3000 diff --git a/frontend/src/components/ApiTest.vue b/frontend/src/components/ApiTest.vue index 543791d..2098452 100644 --- a/frontend/src/components/ApiTest.vue +++ b/frontend/src/components/ApiTest.vue @@ -15,7 +15,7 @@ export default { }, methods: { test() { - fetch('http://localhost:3000/api/test') + fetch('${import.meta.env.VITE_API_URL}/api/test') .then((response) => response.json()) .then((data) => { this.message = data.message diff --git a/frontend/src/components/ChatRoom.vue b/frontend/src/components/ChatRoom.vue index 7585338..6b94f09 100644 --- a/frontend/src/components/ChatRoom.vue +++ b/frontend/src/components/ChatRoom.vue @@ -58,7 +58,7 @@ export default { }, fetchMessages() { axios - .get(`http://localhost:3000/rooms/${this.roomId}/messages`) + .get(`${import.meta.env.VITE_API_URL}/rooms/${this.roomId}/messages`) .then((response) => { this.messages = response.data }) @@ -68,7 +68,7 @@ export default { }, sendMessage() { axios - .post(`http://localhost:3000/rooms/${this.roomId}/messages`, { + .post(`${import.meta.env.VITE_API_URL}/rooms/${this.roomId}/messages`, { content: this.newMessageContent, sender_name: this.senderName, }) diff --git a/frontend/src/components/ChatRooms.vue b/frontend/src/components/ChatRooms.vue index 3c5d11e..932ec58 100644 --- a/frontend/src/components/ChatRooms.vue +++ b/frontend/src/components/ChatRooms.vue @@ -30,7 +30,7 @@ export default { methods: { fetchChatRooms() { axios - .get('http://localhost:3000/rooms') + .get(`${import.meta.env.VITE_API_URL}/rooms`) .then((response) => { this.chatRooms = response.data }) @@ -40,7 +40,7 @@ export default { }, createRoom() { axios - .post('http://localhost:3000/rooms', { + .post(`${import.meta.env.VITE_API_URL}/rooms`, { name: this.newRoomName, }) .then((response) => {