fix(admin-ui): Patch admin path issue (#5154)

This commit is contained in:
Oli Juhl authored and GitHub committed 2023-09-20 16:31:15 +02:00
1 parent 8b189d2b90
commit 54531e38bc
4 files changed
+35 -7

No files matched your search

@@ -0,0 +1,22 @@
/**
* returns the full admin path using the window object
* @returns {string} - admin path
*/
export function getFullAdminPath() {
if (window) {
const origin = window.location.origin // returns base url with trailing slash
const adminPath = process.env.ADMIN_PATH ? `${process.env.ADMIN_PATH}/` : ""
let fullPath = `${origin}${adminPath}`
// safeguard against double slashes, which happens in case path is set to `/`
if (fullPath.endsWith("//")) {
fullPath = adminPath.slice(0, -1)
}
return fullPath
}
return ""
}