From 3240de2c72b13be4463cc196eb2dd5ab218c8ede Mon Sep 17 00:00:00 2001 From: typescreep Date: Wed, 9 Jul 2025 18:49:06 +0300 Subject: [PATCH] new bff location --- package-lock.json | 8 +++--- package.json | 2 +- vite.config.ts | 67 ++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 71 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1494f86..4911ce8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "@ant-design/icons": "5.6.0", "@monaco-editor/react": "4.6.0", "@originjs/vite-plugin-federation": "1.3.6", - "@prorobotech/openapi-k8s-toolkit": "^0.0.1-alpha.49", + "@prorobotech/openapi-k8s-toolkit": "^0.0.1-alpha.50", "@readme/openapi-parser": "4.0.0", "@reduxjs/toolkit": "2.2.5", "@tanstack/react-query": "5.62.2", @@ -2807,9 +2807,9 @@ } }, "node_modules/@prorobotech/openapi-k8s-toolkit": { - "version": "0.0.1-alpha.49", - "resolved": "https://registry.npmjs.org/@prorobotech/openapi-k8s-toolkit/-/openapi-k8s-toolkit-0.0.1-alpha.49.tgz", - "integrity": "sha512-Ms2aM7rKGcnDbdpB1VL8qqAgzsA0O/JkMHX7z7SsvEL6XQ8qiSRVnSxXIierxLry6F0IO5vK7RbV50qwOTTe1g==", + "version": "0.0.1-alpha.50", + "resolved": "https://registry.npmjs.org/@prorobotech/openapi-k8s-toolkit/-/openapi-k8s-toolkit-0.0.1-alpha.50.tgz", + "integrity": "sha512-0kdYPnSwHm2harlIVMezqj6LUgKD7+xe6RXY2ztp7vIO7r9HSLt/CIYXLu7XxgIN+x4aBsrOl0j9NbW1kQj9oA==", "license": "MIT", "dependencies": { "@monaco-editor/react": "4.6.0", diff --git a/package.json b/package.json index bab6bb2..053cf66 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "@ant-design/icons": "5.6.0", "@monaco-editor/react": "4.6.0", "@originjs/vite-plugin-federation": "1.3.6", - "@prorobotech/openapi-k8s-toolkit": "0.0.1-alpha.49", + "@prorobotech/openapi-k8s-toolkit": "0.0.1-alpha.50", "@readme/openapi-parser": "4.0.0", "@reduxjs/toolkit": "2.2.5", "@tanstack/react-query": "5.62.2", diff --git a/vite.config.ts b/vite.config.ts index a5125c3..55c740a 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -66,11 +66,50 @@ export default defineConfig({ open: '/openapi-ui', proxy: { '^/api/clusters/.*/k8s/': { + // '/api': { target: `${options?.KUBE_API_URL}/api/clusters`, changeOrigin: true, secure: false, ws: true, rewrite: path => path.replace(/^\/api\/clusters\//, '/'), + // bypass: function (req, res, proxyOptions) { + // const url = req.url || '' + // if (/^\/api\/clusters\/[^/]+\/k8s\//.test(url)) { + // req.url = url.replace(/^\/api\/clusters\//, '/') + // proxyOptions.target = `${options?.KUBE_API_URL}/api/clusters` + // } else if (/^\/api\/clusters\/[^/]+\/openapi-bff/.test(url)) { + // console.log(req.url) + // proxyOptions.target = options?.BFF_URL + // } + + // return null // continue proxy + // }, + // configure: (proxy, _options) => { + // proxy.on('error', (err, _req, _res) => { + // console.log('proxy error', err) + // }) + // proxy.on('proxyReq', (proxyReq, req, _res) => { + // console.log( + // 'Sending Request:', + // req.method, + // req.url, + // ' => TO THE TARGET => ', + // proxyReq.method, + // proxyReq.protocol, + // proxyReq.host, + // proxyReq.path, + // JSON.stringify(proxyReq.getHeaders()), + // ) + // }) + // proxy.on('proxyRes', (proxyRes, req, _res) => { + // console.log( + // 'Received Response from the Target:', + // proxyRes.statusCode, + // req.url, + // JSON.stringify(proxyRes.headers), + // ) + // }) + // }, }, '/clusterlist': { target: `${options?.KUBE_API_URL}/clusterlist`, @@ -78,11 +117,37 @@ export default defineConfig({ secure: false, rewrite: path => path.replace(/^\/clusterlist/, ''), }, - '/openapi-bff': { + '^/api/clusters/.*/openapi-bff': { target: options?.BFF_URL, changeOrigin: true, secure: false, // rewrite: path => path.replace(/^\/bff/, ''), + // configure: (proxy, _options) => { + // proxy.on('error', (err, _req, _res) => { + // console.log('proxy error', err) + // }) + // proxy.on('proxyReq', (proxyReq, req, _res) => { + // console.log( + // 'Sending Request:', + // req.method, + // req.url, + // ' => TO THE TARGET => ', + // proxyReq.method, + // proxyReq.protocol, + // proxyReq.host, + // proxyReq.path, + // JSON.stringify(proxyReq.getHeaders()), + // ) + // }) + // proxy.on('proxyRes', (proxyRes, req, _res) => { + // console.log( + // 'Received Response from the Target:', + // proxyRes.statusCode, + // req.url, + // JSON.stringify(proxyRes.headers), + // ) + // }) + // }, }, }, },