@vercel/microfrontends 2.1.2 → 2.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1666,19 +1666,24 @@ function routeToLocalProxy() {
1666
1666
 
1667
1667
  // src/next/config/transforms/redirects.ts
1668
1668
  function transform4(args) {
1669
- const { next, microfrontend, opts, app } = args;
1669
+ const { next, microfrontend, opts } = args;
1670
1670
  const isProduction2 = opts?.isProduction ?? false;
1671
1671
  const requireLocalProxyHeader = routeToLocalProxy() && !isProduction2 && !process.env.MFE_DISABLE_LOCAL_PROXY_REWRITE;
1672
1672
  if (requireLocalProxyHeader) {
1673
- const assetPrefix = app.getAssetPrefix();
1674
1673
  const proxyRedirects = [
1675
1674
  {
1676
- source: `/((?!${assetPrefix ? `${assetPrefix}/` : ""}_next/static).*)`,
1675
+ source: `/:path*`,
1677
1676
  destination: `http://localhost:${microfrontend.getLocalProxyPort()}/:path*`,
1678
1677
  permanent: false,
1679
1678
  missing: [
1680
1679
  { type: "header", key: "x-vercel-mfe-local-proxy-origin" }
1681
- ]
1680
+ ],
1681
+ // this fixes relative path Next.js images locally. A security fix removed the headers from the image request,
1682
+ // https://github.com/vercel/next.js/pull/82114, and locally the image fetch does not follow redirects. This
1683
+ // means the header x-vercel-mfe-local-proxy-origin is stripped, and the redirect to then add the header back
1684
+ // in is not followed. As all headers are stripped, there is also no host header, so this check will ensure
1685
+ // relative path Next.js images are not redirected to the local proxy.
1686
+ has: [{ type: "header", key: "host" }]
1682
1687
  }
1683
1688
  ];
1684
1689
  if (next.redirects && typeof next.redirects === "function") {