Skip to content

Commit

Permalink
Merge pull request #5 from rancher-sandbox/feature/rancher-desktop-st…
Browse files Browse the repository at this point in the history
…andalone

Intercept and replace origin in HTTP requests
  • Loading branch information
rak-phillip authored Sep 8, 2022
2 parents 7fafc04 + 48d832f commit f978768
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/release-rancher-desktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ env:
OUTPUT_DIR: dist
RELEASE_DIR: release
ARTIFACT_NAME: rancher-dashboard-desktop-embed
API: "https://127.0.0.1:9443"
RESOURCE_BASE: "https://127.0.0.1:9443"
API: "https://127.0.0.1:6120"
RESOURCE_BASE: "https://127.0.0.1:6120"

jobs:
build:
Expand All @@ -27,7 +27,7 @@ jobs:

- name: Install & Build
run:
ROUTER_BASE="/dashboard" RANCHER_ENV=desktop ./.github/workflows/scripts/build-dashboard.sh
RANCHER_ENV=desktop ./.github/workflows/scripts/build-dashboard.sh

- name: Upload Build
uses: actions/upload-artifact@v2
Expand Down
15 changes: 14 additions & 1 deletion shell/plugins/axios.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { parse as setCookieParser } from 'set-cookie-parser';
import pkg from '../package.json';

export default function({
$axios, $cookies, isDev, req
$axios, $cookies, $config, isDev, req
}) {
$axios.defaults.headers.common['Accept'] = 'application/json';
$axios.defaults.withCredentials = true;
Expand Down Expand Up @@ -64,4 +64,17 @@ export default function({
$axios.defaults.httpsAgent = insecureAgent;
$axios.httpsAgent = insecureAgent;
}

if ($config.rancherEnv === 'desktop') {
$axios.interceptors.request.use((config) => {
if (!config.url.startsWith('http')) {
return config;
}

const url = new URL(config.url);
const urlTrimmed = config.url.replace(`${ url.origin }`, '');

return { ...config, url: urlTrimmed };
});
}
}

0 comments on commit f978768

Please sign in to comment.