我正在除錯基于 Nuxt.js 的 Vue Storefront 專案
我目前面臨的錯誤是:TypeError: Invalid URL資訊量不大。
堆疊跟蹤顯示getIntergrationConfig在src/utils/nuxt檔案夾中。我似乎找不到在我的專案中呼叫的檔案夾或函式。
我怎樣才能追溯我所面臨的錯誤的根源?

uj5u.com熱心網友回復:
通過查看您的錯誤,這似乎與我們的核心如何處理 URL 安裝程序有關。
它getIntegrationConfig是 VSF 核心上的一個函式 ( https://github.com/vuestorefront/vue-storefront/blob/12feb05f644fd21998cd3c69a3f3e576e3359bba/packages/core/core/src/utils/nuxt/_proxyUtils.ts )
它將定義 Nuxt 用于在前端和 VSF API 之間進行通信的 API URL
export const getIntegrationConfig = (context: NuxtContext, configuration: any) => {
const baseURL = process.server ? context?.$config?.middlewareUrl : window.location.origin;
const cookie = getCookies(context);
if (process.server && context?.$config?.middlewareUrl) {
Logger.info('Applied middlewareUrl as ', context.$config.middlewareUrl);
}
return merge({
axios: {
baseURL: new URL(/\/api\//gi.test(baseURL) ? '' : 'api', baseURL).toString(),
headers: {
...(cookie ? { cookie } : {})
}
}
}, configuration);
};
隨著您的錯誤繼續存在,我們看到它將在new URL將建構式傳遞給 URL 類時在類創建中被觸發。
如果我們查看代碼,我們可以假設baseURL沒有正確定義。
我可以建議您在nuxt.config.js檔案中定義服務器中間件 URL(https://docs.vuestorefront.io/v2/security/api-url.html)
我還想邀請您訪問我們的 Discord 服務器,網址為https://discord.gg/vuestorefront
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/471119.html
上一篇:VSCodeMacm1Debug沒有使用MakefileconfC語言達到我的斷點
下一篇:大量OpenGLglDebugOutputShaderStats/ShaderCompiler/Other/帶有mesaradeon的通知嚴重性訊息
