You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by ch...@apache.org on 2023/03/16 14:03:00 UTC
[kyuubi] 01/01: [KYUUBI #4537][UI] Enable Vite proxy server for web ui development
This is an automated email from the ASF dual-hosted git repository.
chengpan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kyuubi.git
commit b7290dc6a923bcea76dd969f2d27e17921a8e7f3
Author: He Zhao <he...@cisco.com>
AuthorDate: Thu Mar 16 21:59:02 2023 +0800
[KYUUBI #4537][UI] Enable Vite proxy server for web ui development
### _Why are the changes needed?_
As title and close #4537
### _How was this patch tested?_
- [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible
- [x] Add screenshots for manual tests if appropriate
- [ ] [Run test](https://kyuubi.readthedocs.io/en/master/develop_tools/testing.html#running-tests) locally before make a pull request
![popo_2023-03-16 16-03-22](https://user-images.githubusercontent.com/52876270/225552935-525d80d6-520f-4570-9aaf-adc4f97dea44.jpg)
Closes #4538 from zwangsheng/KYUUBI_4537.
Closes #4537
2cae68044 [zwangsheng] [KYUUBI #4537] fix
19fc9bd8b [zwangsheng] [KYUUBI #4537] Set 0.0.0.0 for mac & windows
e8cff7853 [zwangsheng] [KYUUBI #4537] Set 0.0.0.0 for mac & windows
8af446ab0 [zwangsheng] [KYUUBI #4537] Remove test code
2897749ef [zwangsheng] [KYUUBI #4537] Remove test code
e714637e2 [zwangsheng] [KYUUBI #4537][Improvement][UI] Enabled Vite Server Proxy for developer work in local with front and backend server
Lead-authored-by: He Zhao <he...@cisco.com>
Co-authored-by: zwangsheng <22...@qq.com>
Signed-off-by: Cheng Pan <ch...@apache.org>
---
.../src/main/scala/org/apache/kyuubi/Utils.scala | 5 +++
.../kyuubi/server/KyuubiRestFrontendService.scala | 5 ++-
kyuubi-server/web-ui/.env.development | 2 +-
kyuubi-server/web-ui/src/utils/request.ts | 2 +-
kyuubi-server/web-ui/vite.config.ts | 41 ++++++++++++++--------
5 files changed, 37 insertions(+), 18 deletions(-)
diff --git a/kyuubi-common/src/main/scala/org/apache/kyuubi/Utils.scala b/kyuubi-common/src/main/scala/org/apache/kyuubi/Utils.scala
index e4fb23936..3a03682ff 100644
--- a/kyuubi-common/src/main/scala/org/apache/kyuubi/Utils.scala
+++ b/kyuubi-common/src/main/scala/org/apache/kyuubi/Utils.scala
@@ -221,6 +221,11 @@ object Utils extends Logging {
*/
val isWindows: Boolean = SystemUtils.IS_OS_WINDOWS
+ /**
+ * Whether the underlying operating system is MacOS.
+ */
+ val isMac: Boolean = SystemUtils.IS_OS_MAC
+
/**
* Indicates whether Kyuubi is currently running unit tests.
*/
diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiRestFrontendService.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiRestFrontendService.scala
index 5a991a08a..cd191afe8 100644
--- a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiRestFrontendService.scala
+++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiRestFrontendService.scala
@@ -58,7 +58,10 @@ class KyuubiRestFrontendService(override val serverable: Serverable)
lazy val host: String = conf.get(FRONTEND_REST_BIND_HOST)
.getOrElse {
- if (conf.get(KyuubiConf.FRONTEND_CONNECTION_URL_USE_HOSTNAME)) {
+ if (Utils.isWindows || Utils.isMac) {
+ warn(s"Kyuubi Server run in Windows or Mac environment, binding $getName to 0.0.0.0")
+ "0.0.0.0"
+ } else if (conf.get(KyuubiConf.FRONTEND_CONNECTION_URL_USE_HOSTNAME)) {
Utils.findLocalInetAddress.getCanonicalHostName
} else {
Utils.findLocalInetAddress.getHostAddress
diff --git a/kyuubi-server/web-ui/.env.development b/kyuubi-server/web-ui/.env.development
index d8297cf36..d1d91dd38 100644
--- a/kyuubi-server/web-ui/.env.development
+++ b/kyuubi-server/web-ui/.env.development
@@ -15,4 +15,4 @@
NODE_ENV=development
-VITE_APP_DEV_WEB_URL='/'
+VITE_APP_DEV_WEB_URL='http://0.0.0.0:10099/'
diff --git a/kyuubi-server/web-ui/src/utils/request.ts b/kyuubi-server/web-ui/src/utils/request.ts
index 375e8f9cc..6171ed9cd 100644
--- a/kyuubi-server/web-ui/src/utils/request.ts
+++ b/kyuubi-server/web-ui/src/utils/request.ts
@@ -19,7 +19,7 @@ import axios, { AxiosResponse } from 'axios'
// create an axios instance
const service = axios.create({
- baseURL: import.meta.env.VITE_APP_DEV_WEB_URL, // url = base url + request url
+ baseURL: '/', // url = base url + request url
// withCredentials: true, // send cookies when cross-domain requests
timeout: 60000 // request timeout
})
diff --git a/kyuubi-server/web-ui/vite.config.ts b/kyuubi-server/web-ui/vite.config.ts
index 92af99741..b6786a0c1 100644
--- a/kyuubi-server/web-ui/vite.config.ts
+++ b/kyuubi-server/web-ui/vite.config.ts
@@ -15,24 +15,35 @@
* limitations under the License.
*/
-import { defineConfig } from 'vite'
+import { defineConfig, loadEnv } from 'vite'
import Vue from '@vitejs/plugin-vue'
import path from 'path'
-export default defineConfig({
- base: '/ui/',
- plugins: [Vue()],
- resolve: {
- alias: [
- {
- find: '@',
- replacement: path.resolve(__dirname, 'src')
- },
- // resolve warning of vue-i18n
- {
- find: 'vue-i18n',
- replacement: 'vue-i18n/dist/vue-i18n.cjs.js'
+export default defineConfig(({ mode }) => {
+ const env = loadEnv(mode, process.cwd(), '')
+ return {
+ base: '/ui/',
+ plugins: [Vue()],
+ resolve: {
+ alias: [
+ {
+ find: '@',
+ replacement: path.resolve(__dirname, 'src')
+ },
+ // resolve warning of vue-i18n
+ {
+ find: 'vue-i18n',
+ replacement: 'vue-i18n/dist/vue-i18n.cjs.js'
+ }
+ ]
+ },
+ server: {
+ proxy: {
+ '/api': {
+ target: env['VITE_APP_DEV_WEB_URL'],
+ changeOrigin: true
+ }
}
- ]
+ }
}
})