@vercel/microfrontends 2.1.0 → 2.1.2
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 +14 -0
- package/dist/bin/cli.cjs +63 -10
- package/dist/next/config.cjs +6 -3
- package/dist/next/config.cjs.map +1 -1
- package/dist/next/config.js +6 -3
- package/dist/next/config.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @vercel/microfrontends
|
|
2
2
|
|
|
3
|
+
## 2.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0606811: Fix local Next.js Image Optimization
|
|
8
|
+
|
|
9
|
+
## 2.1.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 96f0ea5:
|
|
14
|
+
- Add support for locally overriding to MFE aliases: https://vercel.com/changelog/preview-links-between-microfrontends-projects-now-serve-all-paths
|
|
15
|
+
- Fix local Next.js image optimization. Next.js released a security fix which removes headers from being passed on image optimization requests. The microfrontends local proxy previously relied on the headers being passed.
|
|
16
|
+
|
|
3
17
|
## 2.1.0
|
|
4
18
|
|
|
5
19
|
### Minor 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.
|
|
33
|
+
version: "2.1.2",
|
|
34
34
|
private: false,
|
|
35
35
|
description: "Defines configuration and utilities for microfrontends development",
|
|
36
36
|
keywords: [
|
|
@@ -397,6 +397,11 @@ function parseOverrides(cookies) {
|
|
|
397
397
|
return overridesConfig;
|
|
398
398
|
}
|
|
399
399
|
|
|
400
|
+
// src/config/overrides/get-app-env-override-cookie-name.ts
|
|
401
|
+
function getAppEnvOverrideCookieName(application) {
|
|
402
|
+
return `${OVERRIDES_ENV_COOKIE_PREFIX}${application}`;
|
|
403
|
+
}
|
|
404
|
+
|
|
400
405
|
// src/config/microfrontends-config/client/index.ts
|
|
401
406
|
var import_path_to_regexp = require("path-to-regexp");
|
|
402
407
|
var regexpCache = /* @__PURE__ */ new Map();
|
|
@@ -1840,9 +1845,12 @@ var localAuthHtml = ({
|
|
|
1840
1845
|
hostname,
|
|
1841
1846
|
defaultApp,
|
|
1842
1847
|
automationBypassEnvVarName,
|
|
1843
|
-
automationBypass
|
|
1848
|
+
automationBypass,
|
|
1849
|
+
override
|
|
1844
1850
|
}) => {
|
|
1851
|
+
const intro = override ? `<b><code>${app}</code></b> is overriding to a protected deployment <a target="_blank" href="https://${override}">${override}</a>.` : `<b><code>${app}</code></b> is falling back to a protected deployment <a target="_blank" href="https://${hostname}">${hostname}</a>.`;
|
|
1845
1852
|
const content = automationBypass ? `<b><code>${automationBypassEnvVarName}</code></b> is set with the value <b><code>${automationBypass}</code></b>, please verify this value equals the <a href="https://vercel.com/docs/deployment-protection/methods-to-bypass-deployment-protection/protection-bypass-automation">Protection Bypass for Automation</a> for the Vercel project hosting the deployment.` : `To access, set a local environment variable <b><code>${automationBypassEnvVarName}</code></b> with the value of the <a href="https://vercel.com/docs/deployment-protection/methods-to-bypass-deployment-protection/protection-bypass-automation">Protection Bypass for Automation</a> for the Vercel project hosting the deployment.`;
|
|
1853
|
+
const action = override ? `<buttton onClick="clearOverride()" class="button">Clear Override</button>` : "";
|
|
1846
1854
|
return `<!DOCTYPE html>
|
|
1847
1855
|
<html lang="en">
|
|
1848
1856
|
<head>
|
|
@@ -1887,12 +1895,32 @@ var localAuthHtml = ({
|
|
|
1887
1895
|
::-moz-selection {
|
|
1888
1896
|
background: #79FFE1;
|
|
1889
1897
|
}
|
|
1898
|
+
|
|
1899
|
+
.button {
|
|
1900
|
+
border: 1px solid black;
|
|
1901
|
+
padding: 10px 20px;
|
|
1902
|
+
text-align: center;
|
|
1903
|
+
text-decoration: none;
|
|
1904
|
+
display: inline-block;
|
|
1905
|
+
font-size: 16px;
|
|
1906
|
+
margin: 4px 2px;
|
|
1907
|
+
cursor: pointer;
|
|
1908
|
+
border-radius: 5px;
|
|
1909
|
+
align-self: flex-end;
|
|
1910
|
+
font-size: 14px;
|
|
1911
|
+
line-height: 1.8;
|
|
1912
|
+
}
|
|
1913
|
+
|
|
1914
|
+
.button:hover {
|
|
1915
|
+
background-color: #ddd;
|
|
1916
|
+
}
|
|
1890
1917
|
|
|
1891
1918
|
a {
|
|
1892
1919
|
cursor: pointer;
|
|
1893
1920
|
color: #0070f3;
|
|
1894
1921
|
text-decoration: none;
|
|
1895
1922
|
transition: all .2s ease;
|
|
1923
|
+
border-radius: 5px;
|
|
1896
1924
|
border-bottom: 1px solid transparent
|
|
1897
1925
|
}
|
|
1898
1926
|
|
|
@@ -1942,7 +1970,10 @@ var localAuthHtml = ({
|
|
|
1942
1970
|
main {
|
|
1943
1971
|
max-width: 80rem;
|
|
1944
1972
|
padding: 4rem 6rem;
|
|
1945
|
-
margin: auto
|
|
1973
|
+
margin: auto;
|
|
1974
|
+
display: flex;
|
|
1975
|
+
flex-direction: column;
|
|
1976
|
+
row-gap: 32px;
|
|
1946
1977
|
}
|
|
1947
1978
|
|
|
1948
1979
|
ul {
|
|
@@ -1974,7 +2005,7 @@ var localAuthHtml = ({
|
|
|
1974
2005
|
padding: 2rem;
|
|
1975
2006
|
display: flex;
|
|
1976
2007
|
flex-direction: column;
|
|
1977
|
-
margin
|
|
2008
|
+
margin: 0px;
|
|
1978
2009
|
}
|
|
1979
2010
|
|
|
1980
2011
|
.error-code {
|
|
@@ -2121,18 +2152,26 @@ var localAuthHtml = ({
|
|
|
2121
2152
|
}
|
|
2122
2153
|
</style>
|
|
2123
2154
|
</head>
|
|
2155
|
+
<script>
|
|
2156
|
+
function clearOverride() {
|
|
2157
|
+
document.cookie = 'vercel-micro-frontends-override:env:${app}=; expires=Thu, 01 Jan 1970 00:00:00 GMT';
|
|
2158
|
+
window.location.reload();
|
|
2159
|
+
}
|
|
2160
|
+
</script>
|
|
2124
2161
|
<body>
|
|
2125
2162
|
<div class="container">
|
|
2126
2163
|
<main>
|
|
2127
2164
|
<p class="devinfo-container">
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2165
|
+
<span>${intro}</span>
|
|
2166
|
+
<br/>
|
|
2167
|
+
<span>${content}</span>
|
|
2168
|
+
<br/>
|
|
2169
|
+
<span>The environment variable should be set in the default app <b><code>${defaultApp}</code></b>, where the local proxy is running.</span>
|
|
2133
2170
|
</p>
|
|
2134
2171
|
|
|
2135
2172
|
<a href="https://vercel.com/docs/microfrontends/local-development#falling-back-to-protected-deployments"><div class="note">Click here to learn more about setting up the environment variable.</div></a>
|
|
2173
|
+
|
|
2174
|
+
${action}
|
|
2136
2175
|
</main>
|
|
2137
2176
|
</div>
|
|
2138
2177
|
</body>
|
|
@@ -2567,6 +2606,10 @@ var LocalProxy = class {
|
|
|
2567
2606
|
const { hostname, port, path: path7 } = target;
|
|
2568
2607
|
const app = this.router.config.getApplication(target.application);
|
|
2569
2608
|
const automationBypass = process.env[app.getAutomationBypassEnvVarName()];
|
|
2609
|
+
const cookies = (0, import_cookie.parse)(req.headers.cookie || "");
|
|
2610
|
+
const overrideCookieName = getAppEnvOverrideCookieName(
|
|
2611
|
+
target.application
|
|
2612
|
+
);
|
|
2570
2613
|
const requestOptions = {
|
|
2571
2614
|
hostname,
|
|
2572
2615
|
path: path7,
|
|
@@ -2574,6 +2617,15 @@ var LocalProxy = class {
|
|
|
2574
2617
|
headers: {
|
|
2575
2618
|
...req.headers,
|
|
2576
2619
|
host: hostname,
|
|
2620
|
+
cookie: Object.entries(cookies).reduce((acc, [name, value]) => {
|
|
2621
|
+
if (value && // strip the override cookie if present, as this causes an auth redirect. The
|
|
2622
|
+
// override is handled by the local proxy.
|
|
2623
|
+
name !== overrideCookieName && // strip the VERCEL_MFE_DEBUG cookie if present, as this causes an auth redirect
|
|
2624
|
+
name !== "VERCEL_MFE_DEBUG") {
|
|
2625
|
+
acc.push((0, import_cookie.serialize)(name, value));
|
|
2626
|
+
}
|
|
2627
|
+
return acc;
|
|
2628
|
+
}, []).join("; "),
|
|
2577
2629
|
...automationBypass ? { "x-vercel-protection-bypass": automationBypass } : {}
|
|
2578
2630
|
},
|
|
2579
2631
|
port
|
|
@@ -2590,7 +2642,8 @@ var LocalProxy = class {
|
|
|
2590
2642
|
hostname,
|
|
2591
2643
|
defaultApp: defaultApp.packageName || defaultApp.name,
|
|
2592
2644
|
automationBypassEnvVarName: app.getAutomationBypassEnvVarName(),
|
|
2593
|
-
automationBypass
|
|
2645
|
+
automationBypass,
|
|
2646
|
+
override: cookies[overrideCookieName]
|
|
2594
2647
|
})
|
|
2595
2648
|
);
|
|
2596
2649
|
}
|
package/dist/next/config.cjs
CHANGED
|
@@ -1694,16 +1694,19 @@ function routeToLocalProxy() {
|
|
|
1694
1694
|
|
|
1695
1695
|
// src/next/config/transforms/redirects.ts
|
|
1696
1696
|
function transform4(args) {
|
|
1697
|
-
const { next, microfrontend, opts } = args;
|
|
1697
|
+
const { next, microfrontend, opts, app } = 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();
|
|
1701
1702
|
const proxyRedirects = [
|
|
1702
1703
|
{
|
|
1703
|
-
source: "
|
|
1704
|
+
source: `/((?!${assetPrefix ? `${assetPrefix}/` : ""}_next/static).*)`,
|
|
1704
1705
|
destination: `http://localhost:${microfrontend.getLocalProxyPort()}/:path*`,
|
|
1705
1706
|
permanent: false,
|
|
1706
|
-
missing: [
|
|
1707
|
+
missing: [
|
|
1708
|
+
{ type: "header", key: "x-vercel-mfe-local-proxy-origin" }
|
|
1709
|
+
]
|
|
1707
1710
|
}
|
|
1708
1711
|
];
|
|
1709
1712
|
if (next.redirects && typeof next.redirects === "function") {
|