mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: improve front middleware code
This commit is contained in:
parent
3c2a3e6dea
commit
328cde854a
2 changed files with 34 additions and 36 deletions
|
|
@ -5,19 +5,21 @@ export const LEARNHOUSE_DOMAIN = process.env.NEXT_PUBLIC_LEARNHOUSE_DOMAIN;
|
|||
|
||||
export const getAPIUrl = () => LEARNHOUSE_API_URL;
|
||||
export const getBackendUrl = () => LEARNHOUSE_BACKEND_URL;
|
||||
export const getSelfHostedOption = () => (process.env.NEXT_PUBLIC_LEARNHOUSE_SELF_HOSTED === "true" ? true : false);
|
||||
|
||||
// Multi Organization Mode
|
||||
export const isMultiOrgModeEnabled = () => (process.env.NEXT_PUBLIC_LEARNHOUSE_MULTI_ORG === "true" ? true : false);
|
||||
|
||||
export const getUriWithOrg = (orgslug: string, path: string) => {
|
||||
const selfHosted = getSelfHostedOption();
|
||||
if (selfHosted) {
|
||||
return `${LEARNHOUSE_DOMAIN}${path}`;
|
||||
const multi_org = isMultiOrgModeEnabled();
|
||||
if (multi_org) {
|
||||
return `${LEARNHOUSE_HTTP_PROTOCOL}${orgslug}.${LEARNHOUSE_DOMAIN}${path}`;
|
||||
}
|
||||
return `${LEARNHOUSE_HTTP_PROTOCOL}${orgslug}.${LEARNHOUSE_DOMAIN}${path}`;
|
||||
return `${LEARNHOUSE_HTTP_PROTOCOL}${LEARNHOUSE_DOMAIN}${path}`;
|
||||
};
|
||||
|
||||
export const getOrgFromUri = () => {
|
||||
const selfHosted = getSelfHostedOption();
|
||||
if (selfHosted) {
|
||||
const multi_org = isMultiOrgModeEnabled();
|
||||
if (multi_org) {
|
||||
getDefaultOrg();
|
||||
} else {
|
||||
if (typeof window !== "undefined") {
|
||||
|
|
@ -29,8 +31,5 @@ export const getOrgFromUri = () => {
|
|||
};
|
||||
|
||||
export const getDefaultOrg = () => {
|
||||
const selfHosted = getSelfHostedOption();
|
||||
if (selfHosted) {
|
||||
return process.env.NEXT_PUBLIC_LEARNHOUSE_DEFAULT_ORG;
|
||||
}
|
||||
return process.env.NEXT_PUBLIC_LEARNHOUSE_DEFAULT_ORG;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue