mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: use env variables for backend values
This commit is contained in:
parent
186b0e8401
commit
7869b6fd7f
1 changed files with 8 additions and 7 deletions
|
|
@ -1,5 +1,7 @@
|
|||
const LEARNHOUSE_API_URL = "http://localhost:1338/api/";
|
||||
const LEARNHOUSE_BACKEND_URL = "http://localhost:1338/";
|
||||
const LEARNHOUSE_HTTP_PROTOCOL = process.env.NEXT_PUBLIC_LEARNHOUSE_HTTPS === "true" ? "https://" : "http://";
|
||||
const LEARNHOUSE_API_URL = `${process.env.NEXT_PUBLIC_LEARNHOUSE_API_URL}`;
|
||||
const LEARNHOUSE_BACKEND_URL = `${process.env.NEXT_PUBLIC_LEARNHOUSE_BACKEND_URL}`;
|
||||
const LEARNHOUSE_DOMAIN = process.env.NEXT_PUBLIC_LEARNHOUSE_DOMAIN;
|
||||
|
||||
export const getAPIUrl = () => LEARNHOUSE_API_URL;
|
||||
export const getBackendUrl = () => LEARNHOUSE_BACKEND_URL;
|
||||
|
|
@ -7,11 +9,10 @@ export const getSelfHostedOption = () => (process.env.NEXT_PUBLIC_LEARNHOUSE_SEL
|
|||
|
||||
export const getUriWithOrg = (orgslug: string, path: string) => {
|
||||
const selfHosted = getSelfHostedOption();
|
||||
|
||||
if (selfHosted) {
|
||||
return `http://localhost:3000${path}`;
|
||||
return `${LEARNHOUSE_DOMAIN}${path}`;
|
||||
}
|
||||
return `http://${orgslug}.localhost:3000${path}`;
|
||||
return `${LEARNHOUSE_HTTP_PROTOCOL}${orgslug}.${LEARNHOUSE_DOMAIN}${path}`;
|
||||
};
|
||||
|
||||
export const getOrgFromUri = () => {
|
||||
|
|
@ -21,8 +22,8 @@ export const getOrgFromUri = () => {
|
|||
} else {
|
||||
if (typeof window !== "undefined") {
|
||||
const hostname = window.location.hostname;
|
||||
|
||||
return hostname.replace(".localhost", "");
|
||||
|
||||
return hostname.replace(`.${LEARNHOUSE_DOMAIN}`, "");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue