環境変数の設定

This commit is contained in:
Rikuoh Tsujitani 2025-02-15 22:34:19 +09:00
parent db65ab122f
commit 4bc181a924
4 changed files with 6 additions and 5 deletions

1
frontend/.env Normal file
View file

@ -0,0 +1 @@
VITE_API_URL=http://localhost:3000

View file

@ -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

View file

@ -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,
})

View file

@ -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) => {