Merge pull request #41 from PRO-Robotech/feature/BFF

feature/New bff location
This commit is contained in:
typescreep
2025-07-09 18:49:50 +03:00
committed by GitHub
3 changed files with 71 additions and 6 deletions

8
package-lock.json generated
View File

@@ -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",

View File

@@ -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",

View File

@@ -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),
// )
// })
// },
},
},
},