fix(admin-ui): Patch admin path issue (#5154)
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/admin-ui": patch
|
||||||
|
"@medusajs/admin": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(admin-ui): Patch admin path issue
|
||||||
@@ -14,6 +14,7 @@ import Table from "../molecules/table"
|
|||||||
import DeletePrompt from "../organisms/delete-prompt"
|
import DeletePrompt from "../organisms/delete-prompt"
|
||||||
import EditUser from "../organisms/edit-user-modal"
|
import EditUser from "../organisms/edit-user-modal"
|
||||||
import { useTranslation } from "react-i18next"
|
import { useTranslation } from "react-i18next"
|
||||||
|
import { getAdminPath, getFullAdminPath } from "../../utils/get-admin-path"
|
||||||
|
|
||||||
type UserListElement = {
|
type UserListElement = {
|
||||||
entity: any
|
entity: any
|
||||||
@@ -110,9 +111,9 @@ const UserTable: React.FC<UserTableProps> = ({
|
|||||||
return store.invite_link_template
|
return store.invite_link_template
|
||||||
}
|
}
|
||||||
|
|
||||||
return `${window.location.origin}${
|
const adminPath = getFullAdminPath()
|
||||||
process.env.ADMIN_PATH ? `${process.env.ADMIN_PATH}/` : "/"
|
|
||||||
}invite?token={invite_token}`
|
return `${adminPath}invite?token={invite_token}`
|
||||||
}, [store])
|
}, [store])
|
||||||
|
|
||||||
const getInviteTableRow = (invite: Invite, index: number) => {
|
const getInviteTableRow = (invite: Invite, index: number) => {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import i18n from "i18next"
|
|||||||
import LanguageDetector from "i18next-browser-languagedetector"
|
import LanguageDetector from "i18next-browser-languagedetector"
|
||||||
import Backend from "i18next-http-backend"
|
import Backend from "i18next-http-backend"
|
||||||
import { initReactI18next } from "react-i18next"
|
import { initReactI18next } from "react-i18next"
|
||||||
|
import { getFullAdminPath } from "../utils/get-admin-path"
|
||||||
|
|
||||||
export const supportedLanguages = [
|
export const supportedLanguages = [
|
||||||
{
|
{
|
||||||
@@ -22,10 +23,8 @@ export const supportedLanguages = [
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
const backendUrl = window.location.origin
|
const adminPath = getFullAdminPath()
|
||||||
const adminPath = process.env.ADMIN_PATH ? `${process.env.ADMIN_PATH}/` : "/"
|
const pathToLoadFrom = `${adminPath}public/locales/{{lng}}/{{ns}}.json`
|
||||||
|
|
||||||
const pathToLoadFrom = `${backendUrl}${adminPath}public/locales/{{lng}}/{{ns}}.json`
|
|
||||||
|
|
||||||
void i18n
|
void i18n
|
||||||
.use(Backend)
|
.use(Backend)
|
||||||
|
|||||||
@@ -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