From b1f604ada75a4f46562aadcd382c748999097d08 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Thu, 17 Jun 2021 01:26:04 +0800 Subject: [PATCH 1/7] fix: hardcoded baseurl - ref to #264 Signed-off-by: Wing-Kam Wong --- packages/nc-gui/components/changeEnv.vue | 4 +-- .../nc-gui/components/createOrEditProject.vue | 2 +- .../components/project/settings/env.vue | 4 +-- packages/nc-gui/components/project/xcInfo.vue | 3 +- packages/nc-gui/nuxt.config.js | 29 ++----------------- packages/nc-gui/pages/nc/_project_id.vue | 3 +- packages/nc-gui/pages/project/id.vue | 4 +-- .../pages/user/authentication/signin.vue | 12 ++------ .../user/authentication/signup/_token.vue | 5 ++-- .../user/authentication/signup/index.vue | 3 +- packages/nc-gui/plugins/projectLoader.js | 27 ++--------------- packages/nc-gui/store/graphqlClient.js | 5 ++-- packages/nc-gui/store/project.js | 5 ++-- packages/nc-gui/store/sqlMgr.js | 10 +++---- packages/nc-gui/store/users.js | 5 ++-- 15 files changed, 36 insertions(+), 85 deletions(-) diff --git a/packages/nc-gui/components/changeEnv.vue b/packages/nc-gui/components/changeEnv.vue index 94bd2c0653..a28e158bc6 100644 --- a/packages/nc-gui/components/changeEnv.vue +++ b/packages/nc-gui/components/changeEnv.vue @@ -72,8 +72,7 @@ await new Promise(resolve => { const interv = setInterval(() => { axios.create({ - baseURL: process.env.NODE_ENV === 'production' ? './' : 'http://localhost:8080/dashboard', - // baseURL: 'http://localhost:8080/dashboard', + baseURL: `${$axios.defaults.baseURL}/dashboard`, }).get('').then(() => { this.projectReloading = false; clearInterval(interv); @@ -105,6 +104,7 @@ * * @author Naveen MR * @author Pranav C Balan + * @author Wing-Kam Wong * * @license GNU AGPL version 3 or any later version * diff --git a/packages/nc-gui/components/createOrEditProject.vue b/packages/nc-gui/components/createOrEditProject.vue index ef26be9ae3..f5395c4841 100644 --- a/packages/nc-gui/components/createOrEditProject.vue +++ b/packages/nc-gui/components/createOrEditProject.vue @@ -1388,7 +1388,7 @@ export default { this.allSchemas = true; await this.$axios({ url: 'demo', - baseURL: process.env.NODE_ENV === 'production' ? './' : 'http://localhost:8080/dashboard', + baseURL: `${this.$axios.defaults.baseURL}/dashboard`, }); }, diff --git a/packages/nc-gui/components/project/settings/env.vue b/packages/nc-gui/components/project/settings/env.vue index 46b23012e7..1ea1eb7c46 100644 --- a/packages/nc-gui/components/project/settings/env.vue +++ b/packages/nc-gui/components/project/settings/env.vue @@ -62,8 +62,7 @@ export default { await new Promise(resolve => { const interv = setInterval(() => { axios.create({ - baseURL: process.env.NODE_ENV === 'production' ? './' : 'http://localhost:8080/dashboard', - // baseURL: 'http://localhost:8080/dashboard', + baseURL: `${$axios.defaults.baseURL}/dashboard` }).get('').then(() => { this.projectReloading = false; clearInterval(interv); @@ -94,6 +93,7 @@ export default { * * @author Naveen MR * @author Pranav C Balan + * @author Wing-Kam Wong * * @license GNU AGPL version 3 or any later version * diff --git a/packages/nc-gui/components/project/xcInfo.vue b/packages/nc-gui/components/project/xcInfo.vue index d3535c435f..5ba70af562 100644 --- a/packages/nc-gui/components/project/xcInfo.vue +++ b/packages/nc-gui/components/project/xcInfo.vue @@ -241,7 +241,7 @@ export default { async created() { await this.loadProjectApiInfo(); try { - this.iframeUrl = this._isDev ? 'http://localhost:8080/dashboard/status' : './status'; + this.iframeUrl = `${this.$axios.defaults.baseURL}/dashboard/status`; const res = await this.$axios.get(this.iframeUrl); this.showinfoIFrame = true; } catch (e) { @@ -322,6 +322,7 @@ iframe { * * @author Naveen MR * @author Pranav C Balan + * @author Wing-Kam Wong * * @license GNU AGPL version 3 or any later version * diff --git a/packages/nc-gui/nuxt.config.js b/packages/nc-gui/nuxt.config.js index 3d66319d86..62daee9c1c 100644 --- a/packages/nc-gui/nuxt.config.js +++ b/packages/nc-gui/nuxt.config.js @@ -90,9 +90,7 @@ export default { ** See https://axios.nuxtjs.org/options */ axios: { - baseURL: process.env.NODE_ENV === 'production' ? '../' : 'http://localhost:8080/', - // baseURL: 'http://localhost:8080/', - // baseURL: 'http://localhost:8080/', + baseURL: process.env.NC_BACKEND_URL || 'http://localhost:8080', }, /* ** vuetify module configuration @@ -217,6 +215,7 @@ export default { * * @author Naveen MR * @author Pranav C Balan + * @author Wing-Kam Wong * * @license GNU AGPL version 3 or any later version * @@ -233,26 +232,4 @@ export default { * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * - */ -/** - * @copyright Copyright (c) 2021, Xgene Cloud Ltd - * - * @author Naveen MR - * @author Pranav C Balan - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ + */ \ No newline at end of file diff --git a/packages/nc-gui/pages/nc/_project_id.vue b/packages/nc-gui/pages/nc/_project_id.vue index 4d2d7adc95..a333ff97d1 100644 --- a/packages/nc-gui/pages/nc/_project_id.vue +++ b/packages/nc-gui/pages/nc/_project_id.vue @@ -47,7 +47,7 @@ export default { this.$router.replace({query: {}}) } try { - hj('stateChange', 'http://localhost:8080/dashboard/#/nc/'); + hj('stateChange', `${this.$axios.defaults.baseURL}/dashboard/#/nc/`); } catch (e) { } }, @@ -112,6 +112,7 @@ export default { * * @author Naveen MR * @author Pranav C Balan + * @author Wing-Kam Wong * * @license GNU AGPL version 3 or any later version * diff --git a/packages/nc-gui/pages/project/id.vue b/packages/nc-gui/pages/project/id.vue index b4c2cd55d8..5d802decc2 100644 --- a/packages/nc-gui/pages/project/id.vue +++ b/packages/nc-gui/pages/project/id.vue @@ -1113,8 +1113,7 @@ export default { } axios.create({ - baseURL: process.env.NODE_ENV === 'production' ? './' : 'http://localhost:8080/dashboard', - // baseURL: 'http://localhost:8080/dashboard', + baseURL: `${$axios.defaults.baseURL}/dashboard`, }).get('').then(() => { toast.goAway(100); this.projectReloading = false; @@ -1692,6 +1691,7 @@ export default { * * @author Naveen MR * @author Pranav C Balan + * @author Wing-Kam Wong * * @license GNU AGPL version 3 or any later version * diff --git a/packages/nc-gui/pages/user/authentication/signin.vue b/packages/nc-gui/pages/user/authentication/signin.vue index 9a8d8e3dd1..46adc3bd13 100644 --- a/packages/nc-gui/pages/user/authentication/signin.vue +++ b/packages/nc-gui/pages/user/authentication/signin.vue @@ -105,11 +105,7 @@
@@ -154,7 +154,7 @@ - + @@ -977,7 +977,7 @@ export default { async loadProjectInfo() { if (this.$route.params.project_id) try { - const {info} = (await this.$axios.get(`/nc/${this.$route.params.project_id}/projectApiInfo`, { + const {info} = (await this.$axios.get(`${this.$axios.defaults.baseURL}/nc/${this.$route.params.project_id}/projectApiInfo`, { headers: { 'xc-auth': this.$store.state.users.token } From 7856e2bc3d0955e07ed3d1b64778f04ea5e067fb Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Sat, 19 Jun 2021 00:18:17 +0800 Subject: [PATCH 4/7] chore: revise based on comments Signed-off-by: Wing-Kam Wong --- packages/nc-gui/components/changeEnv.vue | 2 +- packages/nc-gui/components/project/settings/env.vue | 2 +- packages/nc-gui/pages/project/id.vue | 2 +- packages/nc-gui/pages/user/authentication/signin.vue | 4 ++-- packages/nc-gui/pages/user/authentication/signup/_token.vue | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/nc-gui/components/changeEnv.vue b/packages/nc-gui/components/changeEnv.vue index a28e158bc6..344faa9280 100644 --- a/packages/nc-gui/components/changeEnv.vue +++ b/packages/nc-gui/components/changeEnv.vue @@ -72,7 +72,7 @@ await new Promise(resolve => { const interv = setInterval(() => { axios.create({ - baseURL: `${$axios.defaults.baseURL}/dashboard`, + baseURL: `${this.$axios.defaults.baseURL}/dashboard`, }).get('').then(() => { this.projectReloading = false; clearInterval(interv); diff --git a/packages/nc-gui/components/project/settings/env.vue b/packages/nc-gui/components/project/settings/env.vue index 1ea1eb7c46..bc581bc3be 100644 --- a/packages/nc-gui/components/project/settings/env.vue +++ b/packages/nc-gui/components/project/settings/env.vue @@ -62,7 +62,7 @@ export default { await new Promise(resolve => { const interv = setInterval(() => { axios.create({ - baseURL: `${$axios.defaults.baseURL}/dashboard` + baseURL: `${this.$axios.defaults.baseURL}/dashboard` }).get('').then(() => { this.projectReloading = false; clearInterval(interv); diff --git a/packages/nc-gui/pages/project/id.vue b/packages/nc-gui/pages/project/id.vue index 5d802decc2..c584e06a33 100644 --- a/packages/nc-gui/pages/project/id.vue +++ b/packages/nc-gui/pages/project/id.vue @@ -1113,7 +1113,7 @@ export default { } axios.create({ - baseURL: `${$axios.defaults.baseURL}/dashboard`, + baseURL: `${this.$axios.defaults.baseURL}/dashboard`, }).get('').then(() => { toast.goAway(100); this.projectReloading = false; diff --git a/packages/nc-gui/pages/user/authentication/signin.vue b/packages/nc-gui/pages/user/authentication/signin.vue index 46adc3bd13..4da53273a8 100644 --- a/packages/nc-gui/pages/user/authentication/signin.vue +++ b/packages/nc-gui/pages/user/authentication/signin.vue @@ -105,7 +105,7 @@
@@ -154,7 +154,7 @@