mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-05 23:56:42 +08:00
fix remoteEntry url
This commit is contained in:
@@ -45,8 +45,18 @@ async function fetchRemoteModules(): Promise<RemoteModule[]> {
|
|||||||
* @param modules 远程模块列表
|
* @param modules 远程模块列表
|
||||||
*/
|
*/
|
||||||
function injectRemoteModule(module: RemoteModule): void {
|
function injectRemoteModule(module: RemoteModule): void {
|
||||||
|
// 从浏览器地址栏获取当前地址前缀
|
||||||
|
const baseUrl = new URL(window.location.href)
|
||||||
|
// 环境变量
|
||||||
|
let apiBase = import.meta.env.VITE_API_BASE_URL
|
||||||
|
if (apiBase.startsWith('/')) {
|
||||||
|
apiBase = apiBase.slice(1)
|
||||||
|
}
|
||||||
|
if (apiBase.endsWith('/')) {
|
||||||
|
apiBase = apiBase.slice(0, -1)
|
||||||
|
}
|
||||||
__federation_method_setRemote(module.id, {
|
__federation_method_setRemote(module.id, {
|
||||||
url: () => Promise.resolve(`${import.meta.env.VITE_API_BASE_URL}/${module.url}`),
|
url: () => Promise.resolve(`${baseUrl.origin}/${apiBase}${module.url}`),
|
||||||
format: 'esm',
|
format: 'esm',
|
||||||
from: 'vite',
|
from: 'vite',
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user