fix(admin-ui): Patch admin path issue (#5154)
This commit is contained in:
22
packages/admin-ui/ui/src/utils/get-admin-path.ts
Normal file
22
packages/admin-ui/ui/src/utils/get-admin-path.ts
Normal 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 ""
|
||||
}
|
||||
Reference in New Issue
Block a user