customHeader (#7456)

This commit is contained in:
Vadim Ogievetsky 2019-04-11 21:58:09 -07:00 committed by Fangjin Yang
parent 3854cfd15e
commit 07eb2effe9
2 changed files with 15 additions and 1 deletions

View File

@ -39,6 +39,8 @@ import './console-application.scss';
export interface ConsoleApplicationProps extends React.Props<any> {
hideLegacy: boolean;
baseURL?: string;
customHeaderName?: string;
customHeaderValue?: string;
}
export interface ConsoleApplicationState {
@ -99,6 +101,9 @@ export class ConsoleApplication extends React.Component<ConsoleApplicationProps,
if (props.baseURL) {
axios.defaults.baseURL = props.baseURL;
}
if (props.customHeaderName && props.customHeaderValue) {
axios.defaults.headers.common[props.customHeaderName] = props.customHeaderValue;
}
}
componentDidMount(): void {

View File

@ -30,17 +30,26 @@ const container = document.getElementsByClassName('app-container')[0];
if (!container) throw new Error('container not found');
interface ConsoleConfig {
title?: string;
hideLegacy?: boolean;
baseURL?: string;
customHeaderName?: string;
customHeaderValue?: string;
}
const consoleConfig: ConsoleConfig = (window as any).consoleConfig;
if (typeof consoleConfig.title === 'string') {
window.document.title = consoleConfig.title;
}
ReactDOM.render(
React.createElement(
ConsoleApplication,
{
hideLegacy: Boolean(consoleConfig.hideLegacy),
baseURL: consoleConfig.baseURL
baseURL: consoleConfig.baseURL,
customHeaderName: consoleConfig.customHeaderName,
customHeaderValue: consoleConfig.customHeaderValue
}
) as any,
container