@decocms/blocks 7.28.0-beta.4 → 7.28.0-beta.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/blocks",
3
- "version": "7.28.0-beta.4",
3
+ "version": "7.28.0-beta.5",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=24"
@@ -116,11 +116,16 @@ export function previewApiOriginForHost(
116
116
  * request time: the request path merges the draft override, and an allowlist
117
117
  * readable through the override could be rewritten by the very draft it gates.
118
118
  */
119
- let sitePreviewHosts: string[] = [];
119
+ // globalThis-backed, like the block loader itself: bundlers can duplicate
120
+ // this module across graphs, and a plain module variable set in one instance
121
+ // is invisible to the others. (The MIDDLEWARE runtime is a separate world
122
+ // even so — which is why the page-side gate is the authoritative one and the
123
+ // middleware only hard-gates when the env override is present.)
124
+ const G = globalThis as { __decoDraftHosts?: string[] };
120
125
 
121
126
  /** Install the site-declared preview hosts. Called by the framework binding at setup. */
122
127
  export function setDraftPreviewHosts(hosts: readonly unknown[]): void {
123
- sitePreviewHosts = hosts
128
+ G.__decoDraftHosts = hosts
124
129
  .filter((h): h is string => typeof h === "string")
125
130
  .map((h) => h.trim().toLowerCase())
126
131
  .filter(Boolean);
@@ -139,7 +144,7 @@ function readAllowedHosts(env: Record<string, string | undefined>): string[] {
139
144
  .split(",")
140
145
  .map((s) => s.trim().toLowerCase())
141
146
  .filter(Boolean);
142
- return fromEnv.length > 0 ? fromEnv : sitePreviewHosts;
147
+ return fromEnv.length > 0 ? fromEnv : (G.__decoDraftHosts ?? []);
143
148
  }
144
149
 
145
150
  /**