Skip to content

Commit

Permalink
allow to modify base path at runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
oavdeev committed Aug 22, 2023
1 parent 51e8a0f commit c660786
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import Announcements from './components/Announcement';
import { PluginsProvider } from './components/Plugins/PluginManager';
import PluginRegisterSystem from './components/Plugins/PluginRegisterSystem';

import { appBasePath } from './constants';

const App: React.FC = () => {
const { t } = useTranslation();
// Features list must be fetched before we render application so we don't render things that
Expand All @@ -46,7 +48,7 @@ const App: React.FC = () => {
<PluginsProvider>
<LoggingProvider>
<GlobalStyle />
<Router basename={process.env.REACT_APP_BASE_PATH}>
<Router basename={appBasePath}>
<QueryParamProvider ReactRouterRoute={Route}>
{flagsReceived ? (
<>
Expand Down
4 changes: 4 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { toRelativeSize } from './utils/style';
declare global {
interface Window {
METAFLOW_SERVICE: string;
APP_BASE_PATH: string | undefined;
FEATURES: FeatureFlags;
MF_DEFAULT_TIME_FILTER_DAYS: string;
}
Expand All @@ -19,6 +20,9 @@ const metaflowServiceUrl = new URL(
window.METAFLOW_SERVICE || process.env.REACT_APP_METAFLOW_SERVICE || '/api',
document.baseURI,
);

export const appBasePath = window.APP_BASE_PATH ?? process.env.REACT_APP_BASE_PATH;

const protocolWs = metaflowServiceUrl.protocol === 'https:' ? 'wss:' : 'ws:';

export const METAFLOW_SERVICE = metaflowServiceUrl.href.replace(/\/$/, '');
Expand Down

0 comments on commit c660786

Please sign in to comment.