@decocms/nextjs 7.28.0-beta.3 → 7.28.0-beta.4

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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/setup.ts +12 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/nextjs",
3
- "version": "7.28.0-beta.3",
3
+ "version": "7.28.0-beta.4",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=24"
@@ -29,8 +29,8 @@
29
29
  "lint:unused": "knip"
30
30
  },
31
31
  "dependencies": {
32
- "@decocms/blocks": "7.28.0-beta.3",
33
- "@decocms/blocks-admin": "7.28.0-beta.3"
32
+ "@decocms/blocks": "7.28.0-beta.4",
33
+ "@decocms/blocks-admin": "7.28.0-beta.4"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "next": ">=15.0.0",
package/src/setup.ts CHANGED
@@ -38,7 +38,7 @@
38
38
  * deploys must ship the directory alongside the server bundle).
39
39
  */
40
40
  import type { ApplySectionConventionsInput } from "@decocms/blocks/cms";
41
- import { applySectionConventions, loadBlocks } from "@decocms/blocks/cms";
41
+ import { applySectionConventions, loadBlocks, setDraftPreviewHosts } from "@decocms/blocks/cms";
42
42
  import { loadDecofileDirectory } from "@decocms/blocks/cms/loadDecofileDirectory";
43
43
  import { createSiteSetup, type SiteSetupOptions } from "@decocms/blocks/setup";
44
44
 
@@ -121,6 +121,17 @@ export function createNextSetup(options: NextSetupOptions): () => Promise<void>
121
121
  : await loadDecofileDirectory(options.blocksDir ?? ".deco/blocks");
122
122
  const blocks = { ...dirBlocks, ...options.blocks };
123
123
 
124
+ // Draft preview opt-in from the repo itself: the global `site` block may
125
+ // declare `previewHosts` (e.g. ["fila.vtex.app", "localhost:3100"]).
126
+ // Read here, from the SETUP-TIME base blocks — never via loadBlocks()
127
+ // at request time, where the draft override is merged in: an allowlist
128
+ // readable through the override could be rewritten by the very draft it
129
+ // gates. DECO_ALLOWED_PREVIEW_HOSTS remains an operational override.
130
+ const siteBlock = blocks.site as { previewHosts?: unknown } | undefined;
131
+ if (Array.isArray(siteBlock?.previewHosts)) {
132
+ setDraftPreviewHosts(siteBlock.previewHosts);
133
+ }
134
+
124
135
  createSiteSetup({
125
136
  sections: options.sections,
126
137
  blocks,