basepath config as singleton
This commit is contained in:
parent
e3643217de
commit
b991b1af26
@ -2,6 +2,7 @@ import yaml from 'js-yaml';
|
||||
import { currentBackend } from '../backends/backend';
|
||||
import { authenticate } from '../actions/auth';
|
||||
import * as MediaProxy from '../valueObjects/MediaProxy';
|
||||
import basePath from '../routing/basePath';
|
||||
|
||||
export const CONFIG_REQUEST = 'CONFIG_REQUEST';
|
||||
export const CONFIG_SUCCESS = 'CONFIG_SUCCESS';
|
||||
@ -43,7 +44,7 @@ export function loadConfig(config) {
|
||||
return (dispatch, getState) => {
|
||||
dispatch(configLoading());
|
||||
|
||||
fetch('/config.yml').then((response) => {
|
||||
fetch(`${basePath}/config.yml`).then((response) => {
|
||||
if (response.status !== 200) {
|
||||
throw `Failed to load config.yml (${response.status})`;
|
||||
}
|
||||
|
10
src/routing/basePath.js
Normal file
10
src/routing/basePath.js
Normal file
@ -0,0 +1,10 @@
|
||||
const base = document.querySelector('base');
|
||||
|
||||
let basePath;
|
||||
if (base && base.href) {
|
||||
basePath = base.attributes.getNamedItem('href').value;
|
||||
} else {
|
||||
basePath = '';
|
||||
}
|
||||
|
||||
export default basePath;
|
@ -1,10 +1,10 @@
|
||||
import { createHistory } from 'history';
|
||||
import { useRouterHistory } from 'react-router';
|
||||
import { syncHistoryWithStore } from 'react-router-redux';
|
||||
import basePath from './basePath';
|
||||
|
||||
const base = document.querySelector('base');
|
||||
let history = useRouterHistory(createHistory)({
|
||||
basename: base && base.href || ''
|
||||
basename: basePath
|
||||
});
|
||||
|
||||
const syncHistory = (store) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user