環境変数の設定
This commit is contained in:
parent
db65ab122f
commit
4bc181a924
4 changed files with 6 additions and 5 deletions
frontend
1
frontend/.env
Normal file
1
frontend/.env
Normal file
|
@ -0,0 +1 @@
|
|||
VITE_API_URL=http://localhost:3000
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
})
|
||||
|
|
|
@ -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) => {
|
||||
|
|
Loading…
Reference in a new issue