mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: use subdomains for organizations
This commit is contained in:
parent
600bb96603
commit
fac6b57ab3
16 changed files with 57 additions and 60 deletions
|
|
@ -10,7 +10,10 @@ interface LoginAndGetTokenResponse {
|
|||
|
||||
export async function loginAndGetToken(username: string, password: string): Promise<LoginAndGetTokenResponse> {
|
||||
// Request Config
|
||||
const HeadersConfig = new Headers({ "Content-Type": "application/x-www-form-urlencoded" , Origin: "http://localhost:3000" });
|
||||
|
||||
// get origin
|
||||
const origin = window.location.origin;
|
||||
const HeadersConfig = new Headers({ "Content-Type": "application/x-www-form-urlencoded" , Origin: origin });
|
||||
const urlencoded = new URLSearchParams({ username: username, password: password });
|
||||
|
||||
const requestOptions: any = {
|
||||
|
|
@ -28,7 +31,8 @@ export async function loginAndGetToken(username: string, password: string): Prom
|
|||
}
|
||||
|
||||
export async function getUserInfo(token: string): Promise<any> {
|
||||
const HeadersConfig = new Headers({ Authorization: `Bearer ${token}`, Origin: "http://localhost:3000" });
|
||||
const origin = window.location.origin;
|
||||
const HeadersConfig = new Headers({ Authorization: `Bearer ${token}`, Origin:origin });
|
||||
|
||||
const requestOptions: any = {
|
||||
method: "GET",
|
||||
|
|
|
|||
|
|
@ -6,16 +6,13 @@ export const getAPIUrl = () => LEARNHOUSE_API_URL;
|
|||
export const getBackendUrl = () => LEARNHOUSE_BACKEND_URL;
|
||||
|
||||
export const getUriWithOrg = (orgslug: string, path: string) => {
|
||||
return `http://localhost:3000/org/${orgslug}${path}`;
|
||||
return `http://${orgslug}.localhost:3000${path}`;
|
||||
};
|
||||
|
||||
export const getOrgFromUri = (uri: any) => {
|
||||
// if url contains /org
|
||||
if (uri.includes("/org/")) {
|
||||
let org = uri.match(/\/org\/([\w]+)/)[1];
|
||||
return org;
|
||||
}
|
||||
else {
|
||||
return "";
|
||||
}
|
||||
export const getOrgFromUri = () => {
|
||||
const hostname = window.location.hostname;
|
||||
// get the orgslug from the hostname
|
||||
const orgslug = hostname.split(".")[0];
|
||||
return orgslug;
|
||||
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue