Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load the local hostname's config, where possible #2071

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
Open
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions src/app/components/ClientConfigLoader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,26 @@ import { ClientConfig } from '../hooks/useClientConfig';
import { trimTrailingSlash } from '../utils/common';

const getClientConfig = async (): Promise<ClientConfig> => {
const url = `${trimTrailingSlash(import.meta.env.BASE_URL)}/config.json`;
const config = await fetch(url, { method: 'GET' });
return config.json();
let url = `${trimTrailingSlash(import.meta.env.BASE_URL)}/config.${window.location.hostname}.json`;
let config = await fetch(url, { method: 'GET' });

let loadedConfig = null;
try {
if(config.ok && import.meta.env.MODE != "development") {
loadedConfig = await config.json();
}
} catch (e) {}

if(!loadedConfig) {
url = `${trimTrailingSlash(import.meta.env.BASE_URL)}/config.json`;
config = await fetch(url, { method: 'GET' });
try {
loadedConfig = await config.json();
} catch (e) {
return {};
}
}
nexy7574 marked this conversation as resolved.
Show resolved Hide resolved
nexy7574 marked this conversation as resolved.
Show resolved Hide resolved
return loadedConfig;
};

type ClientConfigLoaderProps = {
Expand Down
Loading