Fix epinio standalone

This commit is contained in:
Richard Cox 2022-04-26 15:50:52 +01:00
parent f76a1bc4a7
commit 8dc2f1b665
3 changed files with 22 additions and 11 deletions

View File

@ -59,11 +59,15 @@ export default {
return await ps
.then((prependPath = opt?.prependPath) => {
if (isSingleProduct) {
const url = parseUrl(opt.url);
if (opt.url.startsWith('/')) {
opt.url = prependPath + opt.url;
} else {
const url = parseUrl(opt.url);
if (!url.path.startsWith(prependPath)) {
url.path = prependPath + url.path;
opt.url = unParseUrl(url);
if (!url.path.startsWith(prependPath)) {
url.path = prependPath + url.path;
opt.url = unParseUrl(url);
}
}
} else {
const currentClusterId = clusterId || rootGetters['clusterId'];

View File

@ -244,8 +244,9 @@ export default function(dir, _appConfig) {
if ( pl !== STANDARD ) {
console.log(`PL: ${ pl }`); // eslint-disable-line no-console
}
const rancherEnv = process.env.RANCHER_ENV || 'web';
console.log(`API: ${ api }`); // eslint-disable-line no-console
console.log(`API: '${ api }'. Env: '${ rancherEnv }'`); // eslint-disable-line no-console
const config = {
dev,
@ -257,9 +258,10 @@ export default function(dir, _appConfig) {
dev,
pl,
perfTest,
rancherEnv
},
publicRuntimeConfig: { rancherEnv: process.env.RANCHER_ENV || 'web' },
publicRuntimeConfig: { rancherEnv },
buildDir: dev ? '.nuxt' : '.nuxt-prod',
@ -562,6 +564,7 @@ export default function(dir, _appConfig) {
// Proxy: https://github.com/nuxt-community/proxy-module#options
proxy: {
'/k8s': proxyWsOpts(api), // Straight to a remote cluster (/k8s/clusters/<id>/)
'/pp': proxyWsOpts(api), // For (epinio) standalone API
'/api': proxyWsOpts(api), // Management k8s API
'/apis': proxyWsOpts(api), // Management k8s API
'/v1': proxyWsOpts(api), // Management Steve API

View File

@ -20,14 +20,18 @@ export default {
// FIXME: RC Standalone - Tech Debt move this to steve store get/set prependPath
// Cover cases where the steve store isn't actually going out to steve (epinio standalone)
const prependPath = process.env.rancherEnv === 'epinio' ? `/pp/v1/epinio/rancher` : '';
const prependPath = this.$config.rancherEnv === 'epinio' ? `/pp/v1/epinio/rancher` : '';
if (prependPath) {
const url = parseUrl(opt.url);
if (opt.url.startsWith('/')) {
opt.url = prependPath + opt.url;
} else {
const url = parseUrl(opt.url);
if (!url.path.startsWith(prependPath)) {
url.path = prependPath + url.path;
opt.url = unParseUrl(url);
if (!url.path.startsWith(prependPath)) {
url.path = prependPath + url.path;
opt.url = unParseUrl(url);
}
}
}