fix: make remoteEntry resolution robust for relative paths

This commit is contained in:
Kyryll O 2026-05-25 16:04:36 +03:00
parent 90d6298f1c
commit 3d0dbd694b
1 changed files with 15 additions and 2 deletions

View File

@ -75,8 +75,21 @@ export class CoreService {
try { try {
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8')); const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
if (process.env.PUBLIC_URL) { if (process.env.PUBLIC_URL) {
const p = manifest.remoteEntry ? new URL(manifest.remoteEntry).pathname : '/remoteEntry.js'; let p = '/remoteEntry.js';
manifest.remoteEntry = `${process.env.PUBLIC_URL}${p}`; if (manifest.remoteEntry) {
try {
if (manifest.remoteEntry.startsWith('http://') || manifest.remoteEntry.startsWith('https://')) {
p = new URL(manifest.remoteEntry).pathname;
} else {
p = manifest.remoteEntry;
}
} catch (e) {
p = manifest.remoteEntry;
}
}
const publicUrl = process.env.PUBLIC_URL.endsWith('/') ? process.env.PUBLIC_URL.slice(0, -1) : process.env.PUBLIC_URL;
const pathname = p.startsWith('/') ? p : '/' + p;
manifest.remoteEntry = `${publicUrl}${pathname}`;
} }
manifest.backendUrl = backendUrl; manifest.backendUrl = backendUrl;