remote-components 0.3.5 → 0.3.6
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/dist/app-63L5THIQ.js +12 -0
- package/dist/app-63L5THIQ.js.map +1 -0
- package/dist/app-A5QE7XRH.cjs +12 -0
- package/dist/app-A5QE7XRH.cjs.map +1 -0
- package/dist/chunk-2VQGCACH.js +190 -0
- package/dist/chunk-2VQGCACH.js.map +1 -0
- package/dist/chunk-42N2ZLE2.js +703 -0
- package/dist/chunk-42N2ZLE2.js.map +1 -0
- package/dist/chunk-6IUP26UK.cjs +57 -0
- package/dist/chunk-6IUP26UK.cjs.map +1 -0
- package/dist/chunk-7MVFHOIP.cjs +60 -0
- package/dist/chunk-7MVFHOIP.cjs.map +1 -0
- package/dist/chunk-CREXMFMF.cjs +155 -0
- package/dist/chunk-CREXMFMF.cjs.map +1 -0
- package/dist/chunk-CTUJSWCM.js +215 -0
- package/dist/chunk-CTUJSWCM.js.map +1 -0
- package/dist/chunk-ENYGL5CO.js +11 -0
- package/dist/chunk-ENYGL5CO.js.map +1 -0
- package/dist/chunk-ER73O65F.cjs +703 -0
- package/dist/chunk-ER73O65F.cjs.map +1 -0
- package/dist/chunk-F44NODUS.cjs +709 -0
- package/dist/chunk-F44NODUS.cjs.map +1 -0
- package/dist/chunk-GAXJTFBV.js +20 -0
- package/dist/chunk-GAXJTFBV.js.map +1 -0
- package/dist/chunk-HNZVEIKN.js +358 -0
- package/dist/chunk-HNZVEIKN.js.map +1 -0
- package/dist/chunk-KE7QPAQ4.cjs +21 -0
- package/dist/chunk-KE7QPAQ4.cjs.map +1 -0
- package/dist/chunk-KEPHL25S.js +60 -0
- package/dist/chunk-KEPHL25S.js.map +1 -0
- package/dist/chunk-KKBEMQU7.cjs +670 -0
- package/dist/chunk-KKBEMQU7.cjs.map +1 -0
- package/dist/chunk-KYJWRZ2B.js +709 -0
- package/dist/chunk-KYJWRZ2B.js.map +1 -0
- package/dist/chunk-N5VQR2PW.cjs +215 -0
- package/dist/chunk-N5VQR2PW.cjs.map +1 -0
- package/dist/chunk-OO4AMJWO.js +155 -0
- package/dist/chunk-OO4AMJWO.js.map +1 -0
- package/dist/chunk-R4QFK5TN.cjs +358 -0
- package/dist/chunk-R4QFK5TN.cjs.map +1 -0
- package/dist/chunk-RUWR74XQ.cjs +152 -0
- package/dist/chunk-RUWR74XQ.cjs.map +1 -0
- package/dist/chunk-S2A4TFLS.js +152 -0
- package/dist/chunk-S2A4TFLS.js.map +1 -0
- package/dist/chunk-SHFJ5OQA.cjs +11 -0
- package/dist/chunk-SHFJ5OQA.cjs.map +1 -0
- package/dist/chunk-TCFLEBQM.cjs +20 -0
- package/dist/chunk-TCFLEBQM.cjs.map +1 -0
- package/dist/chunk-W5ESPGHH.js +670 -0
- package/dist/chunk-W5ESPGHH.js.map +1 -0
- package/dist/chunk-X6YKUJKH.js +21 -0
- package/dist/chunk-X6YKUJKH.js.map +1 -0
- package/dist/chunk-XCFYWSLD.cjs +190 -0
- package/dist/chunk-XCFYWSLD.cjs.map +1 -0
- package/dist/chunk-ZPMTZ3KJ.js +57 -0
- package/dist/chunk-ZPMTZ3KJ.js.map +1 -0
- package/dist/config/nextjs.cjs +76 -351
- package/dist/config/nextjs.cjs.map +1 -1
- package/dist/config/nextjs.js +26 -266
- package/dist/config/nextjs.js.map +1 -1
- package/dist/config/webpack.cjs +12 -240
- package/dist/config/webpack.cjs.map +1 -1
- package/dist/config/webpack.js +6 -207
- package/dist/config/webpack.js.map +1 -1
- package/dist/host/html.cjs +128 -2494
- package/dist/host/html.cjs.map +1 -1
- package/dist/host/html.js +45 -2382
- package/dist/host/html.js.map +1 -1
- package/dist/host/nextjs/app/client-only.cjs +53 -2939
- package/dist/host/nextjs/app/client-only.cjs.map +1 -1
- package/dist/host/nextjs/app/client-only.js +31 -2894
- package/dist/host/nextjs/app/client-only.js.map +1 -1
- package/dist/host/proxy/client.cjs +8 -38
- package/dist/host/proxy/client.cjs.map +1 -1
- package/dist/host/proxy/client.js +4 -7
- package/dist/host/proxy/client.js.map +1 -1
- package/dist/host/proxy.cjs +19 -56
- package/dist/host/proxy.cjs.map +1 -1
- package/dist/host/proxy.js +8 -20
- package/dist/host/proxy.js.map +1 -1
- package/dist/host/react.cjs +17 -2870
- package/dist/host/react.cjs.map +1 -1
- package/dist/host/react.js +13 -2837
- package/dist/host/react.js.map +1 -1
- package/dist/internal/host/server/fetch-remote-component.cjs +1 -18
- package/dist/internal/host/server/fetch-remote-component.cjs.map +1 -1
- package/dist/internal/host/server/fetch-remote-component.js +1 -18
- package/dist/internal/host/server/fetch-remote-component.js.map +1 -1
- package/dist/internal/runtime/loaders/component-loader.cjs +5 -2
- package/dist/internal/runtime/loaders/component-loader.cjs.map +1 -1
- package/dist/internal/runtime/loaders/component-loader.js +5 -2
- package/dist/internal/runtime/loaders/component-loader.js.map +1 -1
- package/dist/internal/runtime/turbopack/remote-scope.cjs +1 -5
- package/dist/internal/runtime/turbopack/remote-scope.cjs.map +1 -1
- package/dist/internal/runtime/turbopack/remote-scope.js +1 -5
- package/dist/internal/runtime/turbopack/remote-scope.js.map +1 -1
- package/dist/internal/utils.cjs +1 -1
- package/dist/internal/utils.cjs.map +1 -1
- package/dist/internal/utils.d.ts +5 -5
- package/dist/internal/utils.js +1 -1
- package/dist/internal/utils.js.map +1 -1
- package/dist/remote/html.cjs +15 -314
- package/dist/remote/html.cjs.map +1 -1
- package/dist/remote/html.js +7 -305
- package/dist/remote/html.js.map +1 -1
- package/dist/remote/middleware.cjs +16 -41
- package/dist/remote/middleware.cjs.map +1 -1
- package/dist/script-6W5JRBZK.cjs +26 -0
- package/dist/script-6W5JRBZK.cjs.map +1 -0
- package/dist/script-IFEBOLIA.js +26 -0
- package/dist/script-IFEBOLIA.js.map +1 -0
- package/dist/static-loader-X4TSF5KW.js +11 -0
- package/dist/static-loader-X4TSF5KW.js.map +1 -0
- package/dist/static-loader-ZYD5BO4D.cjs +11 -0
- package/dist/static-loader-ZYD5BO4D.cjs.map +1 -0
- package/dist/turbopack-NPGO3MWS.js +55 -0
- package/dist/turbopack-NPGO3MWS.js.map +1 -0
- package/dist/turbopack-WRMKPNN4.cjs +55 -0
- package/dist/turbopack-WRMKPNN4.cjs.map +1 -0
- package/dist/webpack-DUBHPYD6.js +92 -0
- package/dist/webpack-DUBHPYD6.js.map +1 -0
- package/dist/webpack-KSCMCL7M.cjs +92 -0
- package/dist/webpack-KSCMCL7M.cjs.map +1 -0
- package/package.json +9 -2
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isProxiedUrl
|
|
3
|
+
} from "./chunk-X6YKUJKH.js";
|
|
4
|
+
import {
|
|
5
|
+
CORS_DOCS_URL,
|
|
6
|
+
RC_PROTECTED_REMOTE_FETCH_PATHNAME
|
|
7
|
+
} from "./chunk-ENYGL5CO.js";
|
|
8
|
+
|
|
9
|
+
// src/utils/abort.ts
|
|
10
|
+
function isAbortError(error) {
|
|
11
|
+
if (error instanceof DOMException && error.name === "AbortError") {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
if (error !== null && typeof error === "object" && "name" in error && error.name === "AbortError" && "message" in error && typeof error.message === "string") {
|
|
15
|
+
const e = error;
|
|
16
|
+
return typeof e.code === "number" || e.constructor?.name === "DOMException";
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// src/utils/error.ts
|
|
22
|
+
var RemoteComponentsError = class extends Error {
|
|
23
|
+
code = "REMOTE_COMPONENTS_ERROR";
|
|
24
|
+
constructor(message, options) {
|
|
25
|
+
super(message, options);
|
|
26
|
+
this.name = "RemoteComponentsError";
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
function multipleRemoteComponentsError(url) {
|
|
30
|
+
return new RemoteComponentsError(
|
|
31
|
+
`Multiple Remote Components found at "${url}". When a page exposes multiple Remote Components you must specify the "name" prop to select which one to load.`
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
function failedToFetchRemoteComponentError(url, { status, statusText }, help = "Is the URL correct and accessible?") {
|
|
35
|
+
return new RemoteComponentsError(
|
|
36
|
+
`Failed to fetch Remote Component from "${url}". ${help}`,
|
|
37
|
+
{ cause: new Error(`${status} ${statusText}`) }
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
async function errorFromFailedFetch(originalUrl, resolvedUrl, res) {
|
|
41
|
+
const isProxied = isProxiedUrl(resolvedUrl.href);
|
|
42
|
+
if (isProxied && res) {
|
|
43
|
+
const body = await res.text().catch(() => "");
|
|
44
|
+
return failedProxyFetchError(
|
|
45
|
+
originalUrl,
|
|
46
|
+
resolvedUrl.href,
|
|
47
|
+
res.status,
|
|
48
|
+
body
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
const fallback = failedToFetchRemoteComponentError(
|
|
52
|
+
originalUrl,
|
|
53
|
+
res ?? { status: 0, statusText: "No Response" }
|
|
54
|
+
);
|
|
55
|
+
if (!res)
|
|
56
|
+
return fallback;
|
|
57
|
+
try {
|
|
58
|
+
const body = await res.text();
|
|
59
|
+
const parser = new DOMParser();
|
|
60
|
+
const doc = parser.parseFromString(body, "text/html");
|
|
61
|
+
const errorTemplate = doc.querySelector(
|
|
62
|
+
"template[data-next-error-message]"
|
|
63
|
+
);
|
|
64
|
+
const errorMessage = errorTemplate?.getAttribute("data-next-error-message");
|
|
65
|
+
if (errorMessage) {
|
|
66
|
+
const error = new RemoteComponentsError(errorMessage);
|
|
67
|
+
const errorStack = errorTemplate?.getAttribute("data-next-error-stack");
|
|
68
|
+
if (errorStack) {
|
|
69
|
+
error.stack = errorStack;
|
|
70
|
+
}
|
|
71
|
+
return error;
|
|
72
|
+
}
|
|
73
|
+
} catch (parseError) {
|
|
74
|
+
if (isAbortError(parseError))
|
|
75
|
+
throw parseError;
|
|
76
|
+
}
|
|
77
|
+
return fallback;
|
|
78
|
+
}
|
|
79
|
+
function failedProxiedAssetError(kind, url, resolvedUrl) {
|
|
80
|
+
return new RemoteComponentsError(
|
|
81
|
+
`Failed to load ${kind} "${url}" via proxy "${resolvedUrl}". Ensure withRemoteComponentsHostProxy middleware is configured, "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}" is in the matcher, and the remote URL is included in allowedProxyUrls. See: ${CORS_DOCS_URL}`
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
function failedProxyFetchError(originalUrl, proxyUrl, status, responseBody) {
|
|
85
|
+
if (status === 404) {
|
|
86
|
+
return new RemoteComponentsError(
|
|
87
|
+
`Could not proxy the request to "${originalUrl}" \u2014 the proxy endpoint "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}" returned 404.
|
|
88
|
+
|
|
89
|
+
The host server needs middleware or a route that handles "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}".
|
|
90
|
+
|
|
91
|
+
Proxying requires two pieces:
|
|
92
|
+
1. resolveClientUrl={routeThroughHostProxy} on <RemoteComponent>
|
|
93
|
+
2. Middleware or a route for "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}" on the host server
|
|
94
|
+
|
|
95
|
+
Docs: ${CORS_DOCS_URL}`
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
if (status === 403) {
|
|
99
|
+
const detail = responseBody ? ` ${responseBody}` : "";
|
|
100
|
+
return new RemoteComponentsError(
|
|
101
|
+
`Proxied request to "${proxyUrl}" was forbidden.${detail} See: ${CORS_DOCS_URL}`
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
return new RemoteComponentsError(
|
|
105
|
+
`Proxied request for "${originalUrl}" via "${proxyUrl}" failed with status ${status}. See: ${CORS_DOCS_URL}`
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// src/utils/logger.ts
|
|
110
|
+
var PREFIX = "remote-components";
|
|
111
|
+
var DEBUG = typeof window !== "undefined" && localStorage.getItem("RC_DEBUG") === "true" || typeof process !== "undefined" && process.env.RC_DEBUG === "true";
|
|
112
|
+
function logDebug(location2, message) {
|
|
113
|
+
if (DEBUG) {
|
|
114
|
+
console.debug(`[${PREFIX}:${location2}]: ${message}`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function logWarn(location2, message) {
|
|
118
|
+
console.warn(`[${PREFIX}:${location2}]: ${message}`);
|
|
119
|
+
}
|
|
120
|
+
function logError(location2, message, cause) {
|
|
121
|
+
console.error(
|
|
122
|
+
new RemoteComponentsError(`[${PREFIX}:${location2}]: ${message}`, {
|
|
123
|
+
cause
|
|
124
|
+
})
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
function warnCrossOriginFetchError(logLocation, url) {
|
|
128
|
+
try {
|
|
129
|
+
const parsed = typeof url === "string" ? new URL(url) : url;
|
|
130
|
+
if (typeof location === "undefined" || parsed.origin === location.origin) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
logWarn(
|
|
134
|
+
logLocation,
|
|
135
|
+
`Failed to fetch cross-origin resource "${parsed.href}". To load assets from a protected deployment, two steps are required: (1) configure withRemoteComponentsHostProxy middleware in your host with the remote URL in allowedProxyUrls, and (2) provide a resolveClientUrl prop that rewrites cross-origin asset URLs to go through the proxy. See: ${CORS_DOCS_URL}`
|
|
136
|
+
);
|
|
137
|
+
} catch {
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export {
|
|
142
|
+
isAbortError,
|
|
143
|
+
RemoteComponentsError,
|
|
144
|
+
multipleRemoteComponentsError,
|
|
145
|
+
errorFromFailedFetch,
|
|
146
|
+
failedProxiedAssetError,
|
|
147
|
+
logDebug,
|
|
148
|
+
logWarn,
|
|
149
|
+
logError,
|
|
150
|
+
warnCrossOriginFetchError
|
|
151
|
+
};
|
|
152
|
+
//# sourceMappingURL=chunk-S2A4TFLS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/abort.ts","../src/utils/error.ts","../src/utils/logger.ts"],"sourcesContent":["/**\n * Type guard to check if an error is an AbortError.\n * Handles cross-environment differences (Node.js, browsers, JSDOM).\n */\nexport function isAbortError(error: unknown): error is DOMException {\n if (error instanceof DOMException && error.name === 'AbortError') {\n return true;\n }\n\n // Handle Node.js native AbortError which may not be instanceof global DOMException\n if (\n error !== null &&\n typeof error === 'object' &&\n 'name' in error &&\n error.name === 'AbortError' &&\n 'message' in error &&\n typeof (error as { message: unknown }).message === 'string'\n ) {\n // Additional check: verify it has DOMException-like structure\n const e = error as { code?: unknown; constructor?: { name?: string } };\n return typeof e.code === 'number' || e.constructor?.name === 'DOMException';\n }\n\n return false;\n}\n","import { isProxiedUrl } from '#internal/runtime/url/protected-rc-fallback';\nimport { isAbortError } from '#internal/utils/abort';\nimport {\n CORS_DOCS_URL,\n RC_PROTECTED_REMOTE_FETCH_PATHNAME,\n} from '#internal/utils/constants';\n\nexport class RemoteComponentsError extends Error {\n code = 'REMOTE_COMPONENTS_ERROR';\n\n constructor(message: string, options?: { cause?: unknown }) {\n super(message, options);\n this.name = 'RemoteComponentsError';\n }\n}\n\nexport function multipleRemoteComponentsError(url: string | undefined) {\n return new RemoteComponentsError(\n `Multiple Remote Components found at \"${url}\". When a page exposes multiple Remote Components you must specify the \"name\" prop to select which one to load.`,\n );\n}\n\nexport function failedToFetchRemoteComponentError(\n url: string,\n { status, statusText }: { status: number; statusText: string },\n help: string = 'Is the URL correct and accessible?',\n) {\n return new RemoteComponentsError(\n `Failed to fetch Remote Component from \"${url}\". ${help}`,\n { cause: new Error(`${status} ${statusText}`) },\n );\n}\n\nexport async function errorFromFailedFetch(\n originalUrl: string,\n resolvedUrl: URL,\n res: Response | null | undefined,\n): Promise<RemoteComponentsError> {\n const isProxied = isProxiedUrl(resolvedUrl.href);\n\n if (isProxied && res) {\n const body = await res.text().catch(() => '');\n return failedProxyFetchError(\n originalUrl,\n resolvedUrl.href,\n res.status,\n body,\n );\n }\n\n const fallback = failedToFetchRemoteComponentError(\n originalUrl,\n res ?? { status: 0, statusText: 'No Response' },\n );\n\n if (!res) return fallback;\n\n try {\n const body = await res.text();\n const parser = new DOMParser();\n const doc = parser.parseFromString(body, 'text/html');\n const errorTemplate = doc.querySelector(\n 'template[data-next-error-message]',\n );\n const errorMessage = errorTemplate?.getAttribute('data-next-error-message');\n if (errorMessage) {\n const error = new RemoteComponentsError(errorMessage);\n const errorStack = errorTemplate?.getAttribute('data-next-error-stack');\n if (errorStack) {\n error.stack = errorStack;\n }\n return error;\n }\n } catch (parseError) {\n // Re-throw abort errors, ignore parse errors\n if (isAbortError(parseError)) throw parseError;\n }\n\n return fallback;\n}\n\nexport function failedProxiedAssetError(\n kind: 'chunk' | 'script',\n url: string,\n resolvedUrl: string,\n): RemoteComponentsError {\n return new RemoteComponentsError(\n `Failed to load ${kind} \"${url}\" via proxy \"${resolvedUrl}\". ` +\n `Ensure withRemoteComponentsHostProxy middleware is configured, \"${RC_PROTECTED_REMOTE_FETCH_PATHNAME}\" is in the matcher, ` +\n `and the remote URL is included in allowedProxyUrls. ` +\n `See: ${CORS_DOCS_URL}`,\n );\n}\n\nexport function failedProxyFetchError(\n originalUrl: string,\n proxyUrl: string,\n status: number,\n responseBody?: string,\n): RemoteComponentsError {\n if (status === 404) {\n return new RemoteComponentsError(\n `Could not proxy the request to \"${originalUrl}\" — the proxy endpoint \"${RC_PROTECTED_REMOTE_FETCH_PATHNAME}\" returned 404.\\n\\n` +\n `The host server needs middleware or a route that handles \"${RC_PROTECTED_REMOTE_FETCH_PATHNAME}\".\\n\\n` +\n `Proxying requires two pieces:\\n` +\n ` 1. resolveClientUrl={routeThroughHostProxy} on <RemoteComponent>\\n` +\n ` 2. Middleware or a route for \"${RC_PROTECTED_REMOTE_FETCH_PATHNAME}\" on the host server\\n\\n` +\n `Docs: ${CORS_DOCS_URL}`,\n );\n }\n if (status === 403) {\n const detail = responseBody ? ` ${responseBody}` : '';\n return new RemoteComponentsError(\n `Proxied request to \"${proxyUrl}\" was forbidden.${detail} ` +\n `See: ${CORS_DOCS_URL}`,\n );\n }\n return new RemoteComponentsError(\n `Proxied request for \"${originalUrl}\" via \"${proxyUrl}\" failed with status ${status}. ` +\n `See: ${CORS_DOCS_URL}`,\n );\n}\n","import { CORS_DOCS_URL } from '#internal/utils/constants';\nimport { RemoteComponentsError } from '#internal/utils/error';\n\nexport type LogLocation =\n | 'ChunkLoader'\n | 'ChunkDispatcher'\n | 'ComponentLoader'\n | 'ModuleDispatcher'\n | 'RemoteScope'\n | 'SharedModules'\n | 'WebpackRuntime'\n | 'TurbopackModule'\n | 'StaticLoader'\n | 'ScriptLoader'\n | 'Polyfill'\n | 'HtmlRemote'\n | 'HtmlHost'\n | 'Config'\n | 'NextAppRouter'\n | 'NextAppRouterCompat'\n | 'FetchRemoteComponent'\n | 'SharedModuleResolver';\n\nconst PREFIX = 'remote-components';\nconst DEBUG =\n (typeof window !== 'undefined' &&\n localStorage.getItem('RC_DEBUG') === 'true') ||\n (typeof process !== 'undefined' && process.env.RC_DEBUG === 'true');\n\nexport function logDebug(location: LogLocation, message: string) {\n if (DEBUG) {\n // eslint-disable-next-line no-console\n console.debug(`[${PREFIX}:${location}]: ${message}`);\n }\n}\n\nexport function logInfo(location: LogLocation, message: string) {\n // eslint-disable-next-line no-console\n console.info(`[${PREFIX}:${location}]: ${message}`);\n}\n\nexport function logWarn(location: LogLocation, message: string) {\n // eslint-disable-next-line no-console\n console.warn(`[${PREFIX}:${location}]: ${message}`);\n}\n\nexport function logError(\n location: LogLocation,\n message: string,\n cause?: unknown,\n) {\n // eslint-disable-next-line no-console\n console.error(\n new RemoteComponentsError(`[${PREFIX}:${location}]: ${message}`, {\n cause,\n }),\n );\n}\n\n/**\n * Logs a warning when a cross-origin asset request fails, guiding users\n * to configure the proxy middleware and resolveClientUrl on their host.\n */\nexport function warnCrossOriginFetchError(\n logLocation: LogLocation,\n url: string | URL,\n): void {\n try {\n const parsed = typeof url === 'string' ? new URL(url) : url;\n if (typeof location === 'undefined' || parsed.origin === location.origin) {\n return;\n }\n logWarn(\n logLocation,\n `Failed to fetch cross-origin resource \"${parsed.href}\". ` +\n 'To load assets from a protected deployment, two steps are required: ' +\n '(1) configure withRemoteComponentsHostProxy middleware in your host with the remote URL in allowedProxyUrls, ' +\n 'and (2) provide a resolveClientUrl prop that rewrites cross-origin asset URLs to go through the proxy. ' +\n `See: ${CORS_DOCS_URL}`,\n );\n } catch {\n // URL parsing failed — skip the warning\n }\n}\n"],"mappings":";;;;;;;;;AAIO,SAAS,aAAa,OAAuC;AAClE,MAAI,iBAAiB,gBAAgB,MAAM,SAAS,cAAc;AAChE,WAAO;AAAA,EACT;AAGA,MACE,UAAU,QACV,OAAO,UAAU,YACjB,UAAU,SACV,MAAM,SAAS,gBACf,aAAa,SACb,OAAQ,MAA+B,YAAY,UACnD;AAEA,UAAM,IAAI;AACV,WAAO,OAAO,EAAE,SAAS,YAAY,EAAE,aAAa,SAAS;AAAA,EAC/D;AAEA,SAAO;AACT;;;ACjBO,IAAM,wBAAN,cAAoC,MAAM;AAAA,EAC/C,OAAO;AAAA,EAEP,YAAY,SAAiB,SAA+B;AAC1D,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AAAA,EACd;AACF;AAEO,SAAS,8BAA8B,KAAyB;AACrE,SAAO,IAAI;AAAA,IACT,wCAAwC;AAAA,EAC1C;AACF;AAEO,SAAS,kCACd,KACA,EAAE,QAAQ,WAAW,GACrB,OAAe,sCACf;AACA,SAAO,IAAI;AAAA,IACT,0CAA0C,SAAS;AAAA,IACnD,EAAE,OAAO,IAAI,MAAM,GAAG,UAAU,YAAY,EAAE;AAAA,EAChD;AACF;AAEA,eAAsB,qBACpB,aACA,aACA,KACgC;AAChC,QAAM,YAAY,aAAa,YAAY,IAAI;AAE/C,MAAI,aAAa,KAAK;AACpB,UAAM,OAAO,MAAM,IAAI,KAAK,EAAE,MAAM,MAAM,EAAE;AAC5C,WAAO;AAAA,MACL;AAAA,MACA,YAAY;AAAA,MACZ,IAAI;AAAA,MACJ;AAAA,IACF;AAAA,EACF;AAEA,QAAM,WAAW;AAAA,IACf;AAAA,IACA,OAAO,EAAE,QAAQ,GAAG,YAAY,cAAc;AAAA,EAChD;AAEA,MAAI,CAAC;AAAK,WAAO;AAEjB,MAAI;AACF,UAAM,OAAO,MAAM,IAAI,KAAK;AAC5B,UAAM,SAAS,IAAI,UAAU;AAC7B,UAAM,MAAM,OAAO,gBAAgB,MAAM,WAAW;AACpD,UAAM,gBAAgB,IAAI;AAAA,MACxB;AAAA,IACF;AACA,UAAM,eAAe,eAAe,aAAa,yBAAyB;AAC1E,QAAI,cAAc;AAChB,YAAM,QAAQ,IAAI,sBAAsB,YAAY;AACpD,YAAM,aAAa,eAAe,aAAa,uBAAuB;AACtE,UAAI,YAAY;AACd,cAAM,QAAQ;AAAA,MAChB;AACA,aAAO;AAAA,IACT;AAAA,EACF,SAAS,YAAP;AAEA,QAAI,aAAa,UAAU;AAAG,YAAM;AAAA,EACtC;AAEA,SAAO;AACT;AAEO,SAAS,wBACd,MACA,KACA,aACuB;AACvB,SAAO,IAAI;AAAA,IACT,kBAAkB,SAAS,mBAAmB,iFACuB,mHAE3D;AAAA,EACZ;AACF;AAEO,SAAS,sBACd,aACA,UACA,QACA,cACuB;AACvB,MAAI,WAAW,KAAK;AAClB,WAAO,IAAI;AAAA,MACT,mCAAmC,2CAAsC;AAAA;AAAA,4DACV;AAAA;AAAA;AAAA;AAAA,kCAG1B;AAAA;AAAA,QAC1B;AAAA,IACb;AAAA,EACF;AACA,MAAI,WAAW,KAAK;AAClB,UAAM,SAAS,eAAe,IAAI,iBAAiB;AACnD,WAAO,IAAI;AAAA,MACT,uBAAuB,2BAA2B,eACxC;AAAA,IACZ;AAAA,EACF;AACA,SAAO,IAAI;AAAA,IACT,wBAAwB,qBAAqB,gCAAgC,gBACnE;AAAA,EACZ;AACF;;;AClGA,IAAM,SAAS;AACf,IAAM,QACH,OAAO,WAAW,eACjB,aAAa,QAAQ,UAAU,MAAM,UACtC,OAAO,YAAY,eAAe,QAAQ,IAAI,aAAa;AAEvD,SAAS,SAASA,WAAuB,SAAiB;AAC/D,MAAI,OAAO;AAET,YAAQ,MAAM,IAAI,UAAUA,eAAc,SAAS;AAAA,EACrD;AACF;AAOO,SAAS,QAAQC,WAAuB,SAAiB;AAE9D,UAAQ,KAAK,IAAI,UAAUA,eAAc,SAAS;AACpD;AAEO,SAAS,SACdA,WACA,SACA,OACA;AAEA,UAAQ;AAAA,IACN,IAAI,sBAAsB,IAAI,UAAUA,eAAc,WAAW;AAAA,MAC/D;AAAA,IACF,CAAC;AAAA,EACH;AACF;AAMO,SAAS,0BACd,aACA,KACM;AACN,MAAI;AACF,UAAM,SAAS,OAAO,QAAQ,WAAW,IAAI,IAAI,GAAG,IAAI;AACxD,QAAI,OAAO,aAAa,eAAe,OAAO,WAAW,SAAS,QAAQ;AACxE;AAAA,IACF;AACA;AAAA,MACE;AAAA,MACA,0CAA0C,OAAO,uSAIvC;AAAA,IACZ;AAAA,EACF,QAAE;AAAA,EAEF;AACF;","names":["location","location"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/utils/constants.ts
|
|
2
|
+
var RC_PROTECTED_REMOTE_FETCH_PATHNAME = "/rc-fetch-protected-remote";
|
|
3
|
+
var MISSING_SHARED_MODULES_MESSAGE = "Remote Components shared modules not found. Did you forget to wrap your config with `withRemoteComponentsConfig` on both host and remote?";
|
|
4
|
+
var CORS_DOCS_URL = "https://vercel.com/docs/remote-components/concepts/cors-external-urls#accessing-cross-site-protected-remote-components";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
exports.RC_PROTECTED_REMOTE_FETCH_PATHNAME = RC_PROTECTED_REMOTE_FETCH_PATHNAME; exports.MISSING_SHARED_MODULES_MESSAGE = MISSING_SHARED_MODULES_MESSAGE; exports.CORS_DOCS_URL = CORS_DOCS_URL;
|
|
11
|
+
//# sourceMappingURL=chunk-SHFJ5OQA.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/constants.ts"],"names":[],"mappings":";AAAO,IAAM,qCAAqC;AAE3C,IAAM,iCACX;AAEK,IAAM,gBACX","sourcesContent":["export const RC_PROTECTED_REMOTE_FETCH_PATHNAME = '/rc-fetch-protected-remote';\n\nexport const MISSING_SHARED_MODULES_MESSAGE =\n 'Remote Components shared modules not found. Did you forget to wrap your config with `withRemoteComponentsConfig` on both host and remote?';\n\nexport const CORS_DOCS_URL =\n 'https://vercel.com/docs/remote-components/concepts/cors-external-urls#accessing-cross-site-protected-remote-components';\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/host/server/fetch-headers.ts
|
|
2
|
+
function remoteFetchHeaders() {
|
|
3
|
+
return {
|
|
4
|
+
/**
|
|
5
|
+
* Authenticates deployment protection for the remote. Needed for SSR and SSG clients.
|
|
6
|
+
* If the remote component uses vercel deployment protection, ensure the host and remote vercel
|
|
7
|
+
* projects share a common automation bypass secret, and the shared secret is used as the
|
|
8
|
+
* VERCEL_AUTOMATION_BYPASS_SECRET env var in the host project.
|
|
9
|
+
*/
|
|
10
|
+
...typeof process === "object" && typeof process.env === "object" && typeof process.env.VERCEL_AUTOMATION_BYPASS_SECRET === "string" ? {
|
|
11
|
+
"x-vercel-protection-bypass": process.env.VERCEL_AUTOMATION_BYPASS_SECRET
|
|
12
|
+
} : {},
|
|
13
|
+
Accept: "text/html"
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
exports.remoteFetchHeaders = remoteFetchHeaders;
|
|
20
|
+
//# sourceMappingURL=chunk-TCFLEBQM.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/host/server/fetch-headers.ts"],"names":[],"mappings":";AAGO,SAAS,qBAAqB;AACnC,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOL,GAAI,OAAO,YAAY,YACvB,OAAO,QAAQ,QAAQ,YACvB,OAAO,QAAQ,IAAI,oCAAoC,WACnD;AAAA,MACE,8BACE,QAAQ,IAAI;AAAA,IAChB,IACA,CAAC;AAAA,IACL,QAAQ;AAAA,EACV;AACF","sourcesContent":["/**\n * The headers to use when fetching the remote component.\n */\nexport function remoteFetchHeaders() {\n return {\n /**\n * Authenticates deployment protection for the remote. Needed for SSR and SSG clients.\n * If the remote component uses vercel deployment protection, ensure the host and remote vercel\n * projects share a common automation bypass secret, and the shared secret is used as the\n * VERCEL_AUTOMATION_BYPASS_SECRET env var in the host project.\n */\n ...(typeof process === 'object' &&\n typeof process.env === 'object' &&\n typeof process.env.VERCEL_AUTOMATION_BYPASS_SECRET === 'string'\n ? {\n 'x-vercel-protection-bypass':\n process.env.VERCEL_AUTOMATION_BYPASS_SECRET,\n }\n : {}),\n Accept: 'text/html',\n };\n}\n"]}
|