fix: make remoteEntry resolution robust for relative paths
This commit is contained in:
parent
90d6298f1c
commit
3d0dbd694b
|
|
@ -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;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue