@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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @vercel/microfrontends
2
2
 
3
+ ## 2.1.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 93506f2: Fix Next.js image optimization locally for any image path
8
+
3
9
  ## 2.1.2
4
10
 
5
11
  ### Patch Changes
package/dist/bin/cli.cjs CHANGED
@@ -30,7 +30,7 @@ var import_env = require("@next/env");
30
30
  // package.json
31
31
  var package_default = {
32
32
  name: "@vercel/microfrontends",
33
- version: "2.1.2",
33
+ version: "2.1.3",
34
34
  private: false,
35
35
  description: "Defines configuration and utilities for microfrontends development",
36
36
  keywords: [
@@ -1694,19 +1694,24 @@ function routeToLocalProxy() {
1694
1694
 
1695
1695
  // src/next/config/transforms/redirects.ts
1696
1696
  function transform4(args) {
1697
- const { next, microfrontend, opts, app } = args;
1697
+ const { next, microfrontend, opts } = args;
1698
1698
  const isProduction2 = opts?.isProduction ?? false;
1699
1699
  const requireLocalProxyHeader = routeToLocalProxy() && !isProduction2 && !process.env.MFE_DISABLE_LOCAL_PROXY_REWRITE;
1700
1700
  if (requireLocalProxyHeader) {
1701
- const assetPrefix = app.getAssetPrefix();
1702
1701
  const proxyRedirects = [
1703
1702
  {
1704
- source: `/((?!${assetPrefix ? `${assetPrefix}/` : ""}_next/static).*)`,
1703
+ source: `/:path*`,
1705
1704
  destination: `http://localhost:${microfrontend.getLocalProxyPort()}/:path*`,
1706
1705
  permanent: false,
1707
1706
  missing: [
1708
1707
  { type: "header", key: "x-vercel-mfe-local-proxy-origin" }
1709
- ]
1708
+ ],
1709
+ // this fixes relative path Next.js images locally. A security fix removed the headers from the image request,
1710
+ // https://github.com/vercel/next.js/pull/82114, and locally the image fetch does not follow redirects. This
1711
+ // means the header x-vercel-mfe-local-proxy-origin is stripped, and the redirect to then add the header back
1712
+ // in is not followed. As all headers are stripped, there is also no host header, so this check will ensure
1713
+ // relative path Next.js images are not redirected to the local proxy.
1714
+ has: [{ type: "header", key: "host" }]
1710
1715
  }
1711
1716
  ];
1712
1717
  if (next.redirects && typeof next.redirects === "function") {