CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/customize/app-base-path.ts
Views: 687
1
function init(): string {
2
if (process.env.BASE_PATH) {
3
// This is used by next.js.
4
return process.env.BASE_PATH;
5
}
6
if (typeof window != "undefined" && typeof window.location != "undefined") {
7
// For static frontend we can determine the base url from the window.location
8
const { pathname } = window.location;
9
const i = pathname.lastIndexOf("/static");
10
if (i != -1) {
11
return i == 0 ? "/" : pathname.slice(0, i);
12
}
13
}
14
return "/";
15
}
16
17
export let appBasePath: string = init();
18
19