Skip to content

Commit df76031

Browse files
ScriptedAlchemyDolan Halbrook
andauthored
fix(nextjs-mf): make CSR and SSR image loading consistent in next-mf (#2873) (#2915)
Co-authored-by: Dolan Halbrook <[email protected]> Co-authored-by: ScriptedAlchemy <[email protected]>
1 parent 1386119 commit df76031

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

.changeset/perfect-spies-stare.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@module-federation/nextjs-mf': patch
3+
---
4+
5+
Make CSR and SSR image loading consistent

packages/nextjs-mf/src/loaders/fixImageLoader.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,8 @@ export async function fixImageLoader(
8282
Template.indent([
8383
'try {',
8484
Template.indent([
85-
Template.indent(
86-
`return ${publicPath} && ${publicPath}.indexOf('://') > 0 ? new URL(${publicPath}).origin : ''`,
87-
),
85+
`const splitted = ${publicPath} ? ${publicPath}.split('/_next') : '';`,
86+
`return splitted.length === 2 ? splitted[0] : '';`,
8887
]),
8988
'} catch (e) {',
9089
Template.indent([

0 commit comments

Comments
 (0)