From 0ccd6e6c5d9d5f81ed06c2ae97b1c0fe7e9bd89d Mon Sep 17 00:00:00 2001 From: cascha42 Date: Mon, 17 Jun 2024 15:28:59 +0200 Subject: [PATCH 1/2] Added dynamic base path determination for HTTP requests --- html/index.html | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/html/index.html b/html/index.html index bbcbe2e..a34120e 100644 --- a/html/index.html +++ b/html/index.html @@ -87,7 +87,7 @@ mdi-arrow-up - + mdi-arrow-down @@ -157,7 +157,6 @@ new Vue({ el: '#app', vuetify: new Vuetify(), - http: { root: '/' }, data() { return { configTab: null, @@ -187,10 +186,12 @@ } }, credentialsData: {}, + basePath: '', } }, created() { - this.loadConfig() + this.basePath = window.location.pathname.replace(/\/$/, ''); + this.loadConfig(); }, methods: { moveProcessingCMD(index, down) { @@ -199,7 +200,7 @@ this.configData.handling.processing.splice(index + (down ? -1 : 1), 0, entry) }, loadConfig() { - this.$http.get('/config').then(response => { + this.$http.get(`${this.basePath}/config`).then(response => { const newConfig = response.body newConfig.handling.processing = newConfig.handling.processing.map((x) => { x._id = btoa(JSON.stringify(x)) @@ -208,10 +209,9 @@ this.configData = newConfig }, response => { }) - this.$http.get('/credentials').then(response => { + this.$http.get(`${this.basePath}/credentials`).then(response => { this.credentialsData = response.body - }, response => { - }) + }); }, storeConfig() { const storeConfig = JSON.parse(JSON.stringify(this.configData)) @@ -224,18 +224,18 @@ if (!!x[n] && x[n].length > 0) y[n] = x[n] return y }) - this.$http.post('/config', storeConfig).then(response => { + this.$http.post(`${this.basePath}/config`, storeConfig).then(response => { }) - .then(this.$http.post('/restart')) + .then(() => this.$http.post(`${this.basePath}/restart`)) .then(() => { document.body.style = 'display:none' setTimeout(() => window.location.reload(), 1e3) - }) + }); }, storeCredentials() { - this.$http.post('/credentials', this.credentialsData).then(response => { + this.$http.post(`${this.basePath}/credentials`, this.credentialsData).then(response => { }) - .then(this.$http.post('/restart')) + .then(() => this.$http.post(`${this.basePath}/restart`)) .then(() => { document.body.style = 'display:none' setTimeout(() => window.location.reload(), 1e3) @@ -258,4 +258,4 @@ - \ No newline at end of file + From 43a8e087bb8624d351a00114be133e55ee36d1e4 Mon Sep 17 00:00:00 2001 From: cascha42 Date: Mon, 17 Jun 2024 15:48:50 +0200 Subject: [PATCH 2/2] Added dynamic base path determination for HTTP requests --- html/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/html/index.html b/html/index.html index a34120e..c886b83 100644 --- a/html/index.html +++ b/html/index.html @@ -211,7 +211,7 @@ }) this.$http.get(`${this.basePath}/credentials`).then(response => { this.credentialsData = response.body - }); + }) }, storeConfig() { const storeConfig = JSON.parse(JSON.stringify(this.configData)) @@ -230,7 +230,7 @@ .then(() => { document.body.style = 'display:none' setTimeout(() => window.location.reload(), 1e3) - }); + }) }, storeCredentials() { this.$http.post(`${this.basePath}/credentials`, this.credentialsData).then(response => {