From b1b19ba71a29220abcf7c932a3dc410c0f9ecc48 Mon Sep 17 00:00:00 2001 From: aminecmi Date: Sun, 17 Jul 2022 16:17:08 +0200 Subject: [PATCH] Configurable api base url. --- .gitignore | 3 +++ src/components/ListCreateUpdateModal.vue | 4 ++-- src/views/List.vue | 6 +++--- src/views/Lists.vue | 4 ++-- src/views/Login.vue | 2 +- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 1eb86c4..2d0329a 100644 --- a/.gitignore +++ b/.gitignore @@ -283,3 +283,6 @@ modules.xml package-lock.json + + +.env.production diff --git a/src/components/ListCreateUpdateModal.vue b/src/components/ListCreateUpdateModal.vue index 59800a7..5e5640f 100644 --- a/src/components/ListCreateUpdateModal.vue +++ b/src/components/ListCreateUpdateModal.vue @@ -32,7 +32,7 @@ export default { this.$emit('toggleModal') }, createItem: function () { - fetch('http://localhost:7000/api/lists', { + fetch(`${process.env.VUE_APP_API_BASE_URL}/api/lists`, { method: 'POST', headers: { 'Content-Type': 'application/json;charset=utf-8', @@ -47,7 +47,7 @@ export default { }) }, updateItem: function () { - fetch('http://localhost:7000/api/lists/' + this.item.id, { + fetch(`${process.env.VUE_APP_API_BASE_URL}/api/lists/` + this.item.id, { method: 'PATCH', headers: { 'Content-Type': 'application/json;charset=utf-8', diff --git a/src/views/List.vue b/src/views/List.vue index d281171..880e603 100644 --- a/src/views/List.vue +++ b/src/views/List.vue @@ -66,7 +66,7 @@ export default { if (!ignoreLoading) { this.loading = true; } - fetch('http://localhost:7000/api/lists/' + this.listId + '/items', { + fetch(`${process.env.VUE_APP_API_BASE_URL}/api/lists/' + this.listId + '/items`, { method: 'GET', headers: { 'Content-Type': 'application/json;charset=utf-8', @@ -86,7 +86,7 @@ export default { item.loading = true; const itemCopy = Object.assign({}, item); delete itemCopy.loading; - fetch('http://localhost:7000/api/lists/' + this.listId + '/items/' + item.id, { + fetch(`${process.env.VUE_APP_API_BASE_URL}/api/lists/' + this.listId + '/items/` + item.id, { method: 'PATCH', headers: { 'Content-Type': 'application/json;charset=utf-8', @@ -132,7 +132,7 @@ export default { }; this.updateItem(itemToSend, true); } else { - fetch('http://localhost:7000/api/lists/' + this.listId + '/items', { + fetch(`${process.env.VUE_APP_API_BASE_URL}/api/lists/' + this.listId + '/items`, { method: 'POST', headers: { 'Content-Type': 'application/json;charset=utf-8', diff --git a/src/views/Lists.vue b/src/views/Lists.vue index f6b17e4..ba0f56e 100644 --- a/src/views/Lists.vue +++ b/src/views/Lists.vue @@ -52,7 +52,7 @@ export default { }, methods: { fetchLists: function () { - fetch('http://localhost:7000/api/lists', { + fetch(`${process.env.VUE_APP_API_BASE_URL}/api/lists`, { method: 'GET', headers: { 'Content-Type': 'application/json;charset=utf-8', @@ -65,7 +65,7 @@ export default { }) }, deleteItem: function (item) { - fetch('http://localhost:7000/api/lists/' + item.id, { + fetch(`${process.env.VUE_APP_API_BASE_URL}/api/lists/` + item.id, { method: 'DELETE', headers: { 'Content-Type': 'application/json;charset=utf-8', diff --git a/src/views/Login.vue b/src/views/Login.vue index 1fb9a97..93f6f09 100644 --- a/src/views/Login.vue +++ b/src/views/Login.vue @@ -23,7 +23,7 @@ export default { }, methods: { sendKey: function () { - fetch('http://localhost:7000/api/keys:check', { + fetch(`${process.env.VUE_APP_API_BASE_URL}/api/keys:check`, { method: 'POST', headers: { 'Content-Type': 'application/json;charset=utf-8'