@vercel/microfrontends 1.0.1-canary.0 → 1.0.1-canary.1

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.
@@ -1702,27 +1702,34 @@ function transform2(args) {
1702
1702
  };
1703
1703
  }
1704
1704
 
1705
+ // src/next/utils/route-to-local-proxy.ts
1706
+ function routeToLocalProxy() {
1707
+ const isDevEnv = (process.env.VERCEL_ENV ?? "development") === "development";
1708
+ return isDevEnv && Boolean(process.env.TURBO_TASK_HAS_MFE_PROXY);
1709
+ }
1710
+
1705
1711
  // src/next/config/transforms/redirects.ts
1706
1712
  function transform3(args) {
1707
1713
  const { next, microfrontend, opts } = args;
1708
1714
  const isProduction2 = opts?.isProduction ?? false;
1709
- const isDevEnv = (process.env.VERCEL_ENV ?? "development") === "development";
1710
- const requireLocalProxyHeader = !isProduction2 && isDevEnv && Boolean(process.env.TURBO_TASK_HAS_MFE_PROXY) && !process.env.MFE_DISABLE_LOCAL_PROXY_REWRITE;
1715
+ const requireLocalProxyHeader = routeToLocalProxy() && !isProduction2 && !process.env.MFE_DISABLE_LOCAL_PROXY_REWRITE;
1711
1716
  if (requireLocalProxyHeader) {
1712
- const proxyRedirect = {
1713
- source: "/:path*",
1714
- destination: `http://localhost:${microfrontend.getLocalProxyPort()}/:path*`,
1715
- permanent: false,
1716
- missing: [{ type: "header", key: "x-vercel-mfe-local-proxy-origin" }]
1717
- };
1717
+ const proxyRedirects = [
1718
+ {
1719
+ source: "/:path*",
1720
+ destination: `http://localhost:${microfrontend.getLocalProxyPort()}/:path*`,
1721
+ permanent: false,
1722
+ missing: [{ type: "header", key: "x-vercel-mfe-local-proxy-origin" }]
1723
+ }
1724
+ ];
1718
1725
  if (next.redirects && typeof next.redirects === "function") {
1719
1726
  const originalRedirectsFn = next.redirects;
1720
1727
  next.redirects = async () => {
1721
1728
  const originalRedirects = await originalRedirectsFn();
1722
- return [proxyRedirect, ...originalRedirects];
1729
+ return [...proxyRedirects, ...originalRedirects];
1723
1730
  };
1724
1731
  } else {
1725
- next.redirects = async () => [proxyRedirect];
1732
+ next.redirects = async () => proxyRedirects;
1726
1733
  }
1727
1734
  }
1728
1735
  return { next };