add settings.json

This commit is contained in:
kandrusyak
2022-12-14 15:54:31 +03:00
parent bd8268d848
commit a2dd48be65
7 changed files with 26 additions and 12 deletions

2
dist/index.html vendored
View File

@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="UTF-8"><title>React App</title><link rel="icon" href="favicon.ico"><script defer="defer" src="main.2d9157c3.js"></script></head><body><div id="root"></div><script>function gtag(){dataLayer.push(arguments)}window.dataLayer=window.dataLayer||[],gtag("js",new Date),gtag("config","G-M6E6PDB6Y4")</script><script async src="https://www.googletagmanager.com/gtag/js?id=G-M6E6PDB6Y4"></script></body></html>
<!doctype html><html lang="en"><head><meta charset="UTF-8"><title>React App</title><link rel="icon" href="favicon.ico"><script defer="defer" src="main.3ab1a28d.js"></script></head><body><div id="root"></div><script>function gtag(){dataLayer.push(arguments)}window.dataLayer=window.dataLayer||[],gtag("js",new Date),gtag("config","G-M6E6PDB6Y4")</script><script async src="https://www.googletagmanager.com/gtag/js?id=G-M6E6PDB6Y4"></script></body></html>

File diff suppressed because one or more lines are too long

3
dist/settings.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"API_URL": "https://tn-alpha.idntty.org:8080/api/"
}

3
public/settings.json Normal file
View File

@@ -0,0 +1,3 @@
{
"API_URL": "https://tn-alpha.idntty.org:8080/api/"
}

View File

@@ -4,6 +4,7 @@ import { Buffer } from 'buffer';
import { HashRouter as Router } from 'react-router-dom';
import App from './App';
import { store } from './store/store';
import { fetchWrapper } from './shared/fetchWrapper';
globalThis.Buffer = Buffer;
@@ -13,11 +14,16 @@ BigInt.prototype.toJSON = function () {
return this.toString();
};
ReactDOM.render(
<React.StrictMode>
<Router>
<App />
</Router>
</React.StrictMode>,
document.getElementById('root')
);
fetch('settings.json')
.then((e) => e.json())
.then((data) => (fetchWrapper.baseUrl = data.API_URL))
.then(() =>
ReactDOM.render(
<React.StrictMode>
<Router>
<App />
</Router>
</React.StrictMode>,
document.getElementById('root')
)
);

View File

@@ -3,7 +3,7 @@ import { jsonReplacer } from '../utils/Utils';
function prepareUrl(url) {
if (url.startsWith('http')) return url;
return `${window.location.origin}/api/${url}`;
return `${fetchWrapper.baseUrl}${url}`;
}
function handleRequest(method, url, headers, attempts, token, body) {
@@ -115,3 +115,5 @@ export const fetchWrapper = {
putAuth,
baseUrl: '',
};
fetchWrapper.baseUrl = `${window.location.origin}/api/`;