Fix serverConfig.json fetching behavior across nested routes

Ensure that serverConfig.json is fetched consistently from the root directory regardless of the nested route level. Adjusted the axios request to use an absolute path, specifically targeting the serverConfig.json file in the root directory. This resolves the issue where serverConfig.json was being requested relative to the current route, leading to inconsistencies when navigating across nested routes.
This commit is contained in:
XiaoFans 2024-02-19 00:53:12 +08:00
parent e63e2152d6
commit 04875659ae

View File

@ -31,7 +31,7 @@ export const getServerConfig = async (app: App): Promise<undefined> => {
app.config.globalProperties.$config = getConfig();
return axios({
method: "get",
url: `${VITE_PUBLIC_PATH}serverConfig.json`
url: `${window.location.origin}/serverConfig.json`
})
.then(({ data: config }) => {
let $config = app.config.globalProperties.$config;