mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: improve middleware implementation
This commit is contained in:
parent
ae280b2cfb
commit
aa90283fe7
2 changed files with 36 additions and 29 deletions
|
|
@ -5,14 +5,31 @@ export const getAPIUrl = () => LEARNHOUSE_API_URL;
|
|||
|
||||
export const getBackendUrl = () => LEARNHOUSE_BACKEND_URL;
|
||||
|
||||
export const getSelfHostedOption = () => false;
|
||||
|
||||
export const getUriWithOrg = (orgslug: string, path: string) => {
|
||||
const selfHosted = getSelfHostedOption();
|
||||
if (selfHosted) {
|
||||
return `http://localhost:3000${path}`;
|
||||
}
|
||||
return `http://${orgslug}.localhost:3000${path}`;
|
||||
};
|
||||
|
||||
export const getOrgFromUri = () => {
|
||||
const hostname = window.location.hostname;
|
||||
// get the orgslug from the hostname
|
||||
const orgslug = hostname.split(".")[0];
|
||||
return orgslug;
|
||||
|
||||
const selfHosted = getSelfHostedOption();
|
||||
if (selfHosted) {
|
||||
getDefaultOrg();
|
||||
} else {
|
||||
const hostname = window.location.hostname;
|
||||
// get the orgslug from the hostname
|
||||
const orgslug = hostname.split(".")[0];
|
||||
return orgslug;
|
||||
}
|
||||
};
|
||||
|
||||
export const getDefaultOrg = () => {
|
||||
const selfHosted = getSelfHostedOption();
|
||||
if (selfHosted) {
|
||||
return "test";
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue