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

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

View File

@@ -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 ""
}