remove local config, fetch config at correct url, change title

develop
Alexandre Storelli 6 years ago
parent 2108921f5d
commit 8073ccb62f
  1. 4
      public/config.json
  2. 2
      public/index.html
  3. 10
      src/App.js

@ -1,4 +0,0 @@
{
"default_hs_url": "http://localhost:8008",
"default_is_url": "http://localhost:8008/"
}

@ -24,7 +24,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<title>Watcha admin</title>
</head>
<body>
<noscript>

@ -42,6 +42,8 @@ class App extends Component {
if (loginData['access_token']) {
self.setState({ accessToken: loginData['access_token'] });
return this.state.accessToken;
} else {
throw new Error('no access token');
}
} catch (e) {
console.log('error: ' + e);
@ -52,7 +54,12 @@ class App extends Component {
getserverName = async () => {
let coreUrl = '';
const currentpage = window.location.protocol+'//'+window.location.hostname+'/';
const currentPage = '//' + window.location.hostname + '/';
console.log('old currentPage=' + currentPage);
if (currentPage.includes('-admin')) {
currentPage = currentPage.replace(/-admin/g, '');
}
console.log('new currentPage=' + currentPage);
try {
const configRequest = await fetch(currentpage + '/config.json');
const configData = JSON.parse(await configRequest.text());
@ -65,6 +72,7 @@ class App extends Component {
console.log(coreUrl);
this.setState({ homeserver: coreUrl + '/' });
}
onNameChange = (evt) => {
this.setState({ userName: evt.target.value });
}

Loading…
Cancel
Save